TRPGツール開発・運用Wiki mediawiki https://devops.wiki.trpg.net/wiki/%E3%83%A1%E3%82%A4%E3%83%B3%E3%83%9A%E3%83%BC%E3%82%B8 MediaWiki 1.35.1 case-sensitive メディア 特別 トーク 利用者 利用者・トーク TRPGツール開発・運用Wiki TRPGツール開発・運用Wiki・トーク ファイル ファイル・トーク MediaWiki MediaWiki・トーク テンプレート テンプレート・トーク ヘルプ ヘルプ・トーク カテゴリ カテゴリ・トーク モジュール モジュール・トーク Gadget Gadget talk Gadget definition Gadget definition talk Topic テンプレート:Tl 10 47 95 2016-09-04T13:23:18Z srw>Ochaochaocha3 0 1版 をインポートしました wikitext text/x-wiki <onlyinclude>{{[[Template:{{{1}}}|{{{1}}}]]}}</onlyinclude>{{Documentation}} <!-- カテゴリと言語間リンクはここではなく、/doc サブページに追加してください --> <!-- Add cats and interwikis to the /doc subpage, not here! --> 9c7ac163470965eadcc21e01017e661bc5f001f9 モジュール:Arguments 828 28 59 2016-09-04T14:14:07Z srw>Ochaochaocha3 0 1版 をインポートしました Scribunto text/plain -- This module provides easy processing of arguments passed to Scribunto from -- #invoke. It is intended for use by other Lua modules, and should not be -- called from #invoke directly. local libraryUtil = require('libraryUtil') local checkType = libraryUtil.checkType local arguments = {} -- Generate four different tidyVal functions, so that we don't have to check the -- options every time we call it. local function tidyValDefault(key, val) if type(val) == 'string' then val = val:match('^%s*(.-)%s*$') if val == '' then return nil else return val end else return val end end local function tidyValTrimOnly(key, val) if type(val) == 'string' then return val:match('^%s*(.-)%s*$') else return val end end local function tidyValRemoveBlanksOnly(key, val) if type(val) == 'string' then if val:find('%S') then return val else return nil end else return val end end local function tidyValNoChange(key, val) return val end local function matchesTitle(given, title) local tp = type( given ) return (tp == 'string' or tp == 'number') and mw.title.new( given ).prefixedText == title end local translate_mt = { __index = function(t, k) return k end } function arguments.getArgs(frame, options) checkType('getArgs', 1, frame, 'table', true) checkType('getArgs', 2, options, 'table', true) frame = frame or {} options = options or {} --[[ -- Set up argument translation. --]] options.translate = options.translate or {} if getmetatable(options.translate) == nil then setmetatable(options.translate, translate_mt) end if options.backtranslate == nil then options.backtranslate = {} for k,v in pairs(options.translate) do options.backtranslate[v] = k end end if options.backtranslate and getmetatable(options.backtranslate) == nil then setmetatable(options.backtranslate, { __index = function(t, k) if options.translate[k] ~= k then return nil else return k end end }) end --[[ -- Get the argument tables. If we were passed a valid frame object, get the -- frame arguments (fargs) and the parent frame arguments (pargs), depending -- on the options set and on the parent frame's availability. If we weren't -- passed a valid frame object, we are being called from another Lua module -- or from the debug console, so assume that we were passed a table of args -- directly, and assign it to a new variable (luaArgs). --]] local fargs, pargs, luaArgs if type(frame.args) == 'table' and type(frame.getParent) == 'function' then if options.wrappers then --[[ -- The wrappers option makes Module:Arguments look up arguments in -- either the frame argument table or the parent argument table, but -- not both. This means that users can use either the #invoke syntax -- or a wrapper template without the loss of performance associated -- with looking arguments up in both the frame and the parent frame. -- Module:Arguments will look up arguments in the parent frame -- if it finds the parent frame's title in options.wrapper; -- otherwise it will look up arguments in the frame object passed -- to getArgs. --]] local parent = frame:getParent() if not parent then fargs = frame.args else local title = parent:getTitle():gsub('/sandbox$', '') local found = false if matchesTitle(options.wrappers, title) then found = true elseif type(options.wrappers) == 'table' then for _,v in pairs(options.wrappers) do if matchesTitle(v, title) then found = true break end end end -- We test for false specifically here so that nil (the default) acts like true. if found or options.frameOnly == false then pargs = parent.args end if not found or options.parentOnly == false then fargs = frame.args end end else -- options.wrapper isn't set, so check the other options. if not options.parentOnly then fargs = frame.args end if not options.frameOnly then local parent = frame:getParent() pargs = parent and parent.args or nil end end if options.parentFirst then fargs, pargs = pargs, fargs end else luaArgs = frame end -- Set the order of precedence of the argument tables. If the variables are -- nil, nothing will be added to the table, which is how we avoid clashes -- between the frame/parent args and the Lua args. local argTables = {fargs} argTables[#argTables + 1] = pargs argTables[#argTables + 1] = luaArgs --[[ -- Generate the tidyVal function. If it has been specified by the user, we -- use that; if not, we choose one of four functions depending on the -- options chosen. This is so that we don't have to call the options table -- every time the function is called. --]] local tidyVal = options.valueFunc if tidyVal then if type(tidyVal) ~= 'function' then error( "bad value assigned to option 'valueFunc'" .. '(function expected, got ' .. type(tidyVal) .. ')', 2 ) end elseif options.trim ~= false then if options.removeBlanks ~= false then tidyVal = tidyValDefault else tidyVal = tidyValTrimOnly end else if options.removeBlanks ~= false then tidyVal = tidyValRemoveBlanksOnly else tidyVal = tidyValNoChange end end --[[ -- Set up the args, metaArgs and nilArgs tables. args will be the one -- accessed from functions, and metaArgs will hold the actual arguments. Nil -- arguments are memoized in nilArgs, and the metatable connects all of them -- together. --]] local args, metaArgs, nilArgs, metatable = {}, {}, {}, {} setmetatable(args, metatable) local function mergeArgs(tables) --[[ -- Accepts multiple tables as input and merges their keys and values -- into one table. If a value is already present it is not overwritten; -- tables listed earlier have precedence. We are also memoizing nil -- values, which can be overwritten if they are 's' (soft). --]] for _, t in ipairs(tables) do for key, val in pairs(t) do if metaArgs[key] == nil and nilArgs[key] ~= 'h' then local tidiedVal = tidyVal(key, val) if tidiedVal == nil then nilArgs[key] = 's' else metaArgs[key] = tidiedVal end end end end end --[[ -- Define metatable behaviour. Arguments are memoized in the metaArgs table, -- and are only fetched from the argument tables once. Fetching arguments -- from the argument tables is the most resource-intensive step in this -- module, so we try and avoid it where possible. For this reason, nil -- arguments are also memoized, in the nilArgs table. Also, we keep a record -- in the metatable of when pairs and ipairs have been called, so we do not -- run pairs and ipairs on the argument tables more than once. We also do -- not run ipairs on fargs and pargs if pairs has already been run, as all -- the arguments will already have been copied over. --]] metatable.__index = function (t, key) --[[ -- Fetches an argument when the args table is indexed. First we check -- to see if the value is memoized, and if not we try and fetch it from -- the argument tables. When we check memoization, we need to check -- metaArgs before nilArgs, as both can be non-nil at the same time. -- If the argument is not present in metaArgs, we also check whether -- pairs has been run yet. If pairs has already been run, we return nil. -- This is because all the arguments will have already been copied into -- metaArgs by the mergeArgs function, meaning that any other arguments -- must be nil. --]] if type(key) == 'string' then key = options.translate[key] end local val = metaArgs[key] if val ~= nil then return val elseif metatable.donePairs or nilArgs[key] then return nil end for _, argTable in ipairs(argTables) do local argTableVal = tidyVal(key, argTable[key]) if argTableVal ~= nil then metaArgs[key] = argTableVal return argTableVal end end nilArgs[key] = 'h' return nil end metatable.__newindex = function (t, key, val) -- This function is called when a module tries to add a new value to the -- args table, or tries to change an existing value. if type(key) == 'string' then key = options.translate[key] end if options.readOnly then error( 'could not write to argument table key "' .. tostring(key) .. '"; the table is read-only', 2 ) elseif options.noOverwrite and args[key] ~= nil then error( 'could not write to argument table key "' .. tostring(key) .. '"; overwriting existing arguments is not permitted', 2 ) elseif val == nil then --[[ -- If the argument is to be overwritten with nil, we need to erase -- the value in metaArgs, so that __index, __pairs and __ipairs do -- not use a previous existing value, if present; and we also need -- to memoize the nil in nilArgs, so that the value isn't looked -- up in the argument tables if it is accessed again. --]] metaArgs[key] = nil nilArgs[key] = 'h' else metaArgs[key] = val end end local function translatenext(invariant) local k, v = next(invariant.t, invariant.k) invariant.k = k if k == nil then return nil elseif type(k) ~= 'string' or not options.backtranslate then return k, v else local backtranslate = options.backtranslate[k] if backtranslate == nil then -- Skip this one. This is a tail call, so this won't cause stack overflow return translatenext(invariant) else return backtranslate, v end end end metatable.__pairs = function () -- Called when pairs is run on the args table. if not metatable.donePairs then mergeArgs(argTables) metatable.donePairs = true end return translatenext, { t = metaArgs } end local function inext(t, i) -- This uses our __index metamethod local v = t[i + 1] if v ~= nil then return i + 1, v end end metatable.__ipairs = function (t) -- Called when ipairs is run on the args table. return inext, t, 0 end return args end return arguments 3134ecce8429b810d445e29eae115e2ae4c36c53 モジュール:Category handler 828 29 61 2016-09-04T14:14:08Z srw>Ochaochaocha3 0 1版 をインポートしました Scribunto text/plain -------------------------------------------------------------------------------- -- -- -- CATEGORY HANDLER -- -- -- -- This module implements the {{category handler}} template in Lua, -- -- with a few improvements: all namespaces and all namespace aliases -- -- are supported, and namespace names are detected automatically for -- -- the local wiki. This module requires [[Module:Namespace detect]] -- -- and [[Module:Yesno]] to be available on the local wiki. It can be -- -- configured for different wikis by altering the values in -- -- [[Module:Category handler/config]], and pages can be blacklisted -- -- from categorisation by using [[Module:Category handler/blacklist]]. -- -- -- -------------------------------------------------------------------------------- -- Load required modules local yesno = require('Module:Yesno') -- Lazily load things we don't always need local mShared, mappings local p = {} -------------------------------------------------------------------------------- -- Helper functions -------------------------------------------------------------------------------- local function trimWhitespace(s, removeBlanks) if type(s) ~= 'string' then return s end s = s:match('^%s*(.-)%s*$') if removeBlanks then if s ~= '' then return s else return nil end else return s end end -------------------------------------------------------------------------------- -- CategoryHandler class -------------------------------------------------------------------------------- local CategoryHandler = {} CategoryHandler.__index = CategoryHandler function CategoryHandler.new(data, args) local obj = setmetatable({ _data = data, _args = args }, CategoryHandler) -- Set the title object do local pagename = obj:parameter('demopage') local success, titleObj if pagename then success, titleObj = pcall(mw.title.new, pagename) end if success and titleObj then obj.title = titleObj if titleObj == mw.title.getCurrentTitle() then obj._usesCurrentTitle = true end else obj.title = mw.title.getCurrentTitle() obj._usesCurrentTitle = true end end -- Set suppression parameter values for _, key in ipairs{'nocat', 'categories'} do local value = obj:parameter(key) value = trimWhitespace(value, true) obj['_' .. key] = yesno(value) end do local subpage = obj:parameter('subpage') local category2 = obj:parameter('category2') if type(subpage) == 'string' then subpage = mw.ustring.lower(subpage) end if type(category2) == 'string' then subpage = mw.ustring.lower(category2) end obj._subpage = trimWhitespace(subpage, true) obj._category2 = trimWhitespace(category2) -- don't remove blank values end return obj end function CategoryHandler:parameter(key) local parameterNames = self._data.parameters[key] local pntype = type(parameterNames) if pntype == 'string' or pntype == 'number' then return self._args[parameterNames] elseif pntype == 'table' then for _, name in ipairs(parameterNames) do local value = self._args[name] if value ~= nil then return value end end return nil else error(string.format( 'invalid config key "%s"', tostring(key) ), 2) end end function CategoryHandler:isSuppressedByArguments() return -- See if a category suppression argument has been set. self._nocat == true or self._categories == false or ( self._category2 and self._category2 ~= self._data.category2Yes and self._category2 ~= self._data.category2Negative ) -- Check whether we are on a subpage, and see if categories are -- suppressed based on our subpage status. or self._subpage == self._data.subpageNo and self.title.isSubpage or self._subpage == self._data.subpageOnly and not self.title.isSubpage end function CategoryHandler:shouldSkipBlacklistCheck() -- Check whether the category suppression arguments indicate we -- should skip the blacklist check. return self._nocat == false or self._categories == true or self._category2 == self._data.category2Yes end function CategoryHandler:matchesBlacklist() if self._usesCurrentTitle then return self._data.currentTitleMatchesBlacklist else mShared = mShared or require('Module:Category handler/shared') return mShared.matchesBlacklist( self.title.prefixedText, mw.loadData('Module:Category handler/blacklist') ) end end function CategoryHandler:isSuppressed() -- Find if categories are suppressed by either the arguments or by -- matching the blacklist. return self:isSuppressedByArguments() or not self:shouldSkipBlacklistCheck() and self:matchesBlacklist() end function CategoryHandler:getNamespaceParameters() if self._usesCurrentTitle then return self._data.currentTitleNamespaceParameters else if not mappings then mShared = mShared or require('Module:Category handler/shared') mappings = mShared.getParamMappings(true) -- gets mappings with mw.loadData end return mShared.getNamespaceParameters( self.title, mappings ) end end function CategoryHandler:namespaceParametersExist() -- Find whether any namespace parameters have been specified. -- We use the order "all" --> namespace params --> "other" as this is what -- the old template did. if self:parameter('all') then return true end if not mappings then mShared = mShared or require('Module:Category handler/shared') mappings = mShared.getParamMappings(true) -- gets mappings with mw.loadData end for ns, params in pairs(mappings) do for i, param in ipairs(params) do if self._args[param] then return true end end end if self:parameter('other') then return true end return false end function CategoryHandler:getCategories() local params = self:getNamespaceParameters() local nsCategory for i, param in ipairs(params) do local value = self._args[param] if value ~= nil then nsCategory = value break end end if nsCategory ~= nil or self:namespaceParametersExist() then -- Namespace parameters exist - advanced usage. if nsCategory == nil then nsCategory = self:parameter('other') end local ret = {self:parameter('all')} local numParam = tonumber(nsCategory) if numParam and numParam >= 1 and math.floor(numParam) == numParam then -- nsCategory is an integer ret[#ret + 1] = self._args[numParam] else ret[#ret + 1] = nsCategory end if #ret < 1 then return nil else return table.concat(ret) end elseif self._data.defaultNamespaces[self.title.namespace] then -- Namespace parameters don't exist, simple usage. return self._args[1] end return nil end -------------------------------------------------------------------------------- -- Exports -------------------------------------------------------------------------------- local p = {} function p._exportClasses() -- Used for testing purposes. return { CategoryHandler = CategoryHandler } end function p._main(args, data) data = data or mw.loadData('Module:Category handler/data') local handler = CategoryHandler.new(data, args) if handler:isSuppressed() then return nil end return handler:getCategories() end function p.main(frame, data) data = data or mw.loadData('Module:Category handler/data') local args = require('Module:Arguments').getArgs(frame, { wrappers = data.wrappers, valueFunc = function (k, v) v = trimWhitespace(v) if type(k) == 'number' then if v ~= '' then return v else return nil end else return v end end }) return p._main(args, data) end return p b74dd63857b24904ac452429b11213f18647471f モジュール:Category handler/blacklist 828 30 63 2016-09-04T14:14:09Z srw>Ochaochaocha3 0 1版 をインポートしました Scribunto text/plain -- This module contains the blacklist used by [[Module:Category handler]]. -- Pages that match Lua patterns in this list will not be categorised unless -- categorisation is explicitly requested. return { '^メインページ$', -- don't categorise the main page. -- Don't categorise the following pages or their subpages. -- "%f[/\0]" matches if the next character is "/" or the end of the string. '^Wikipedia:Cascade%-protected items%f[/\0]', '^User:UBX%f[/\0]', -- The userbox "template" space. '^User talk:UBX%f[/\0]', -- Don't categorise subpages of these pages, but allow -- categorisation of the base page. '^Wikipedia:Template メッセージの一覧/.*$', '/過去ログ' -- Don't categorise archives. } 62012c87cb111349a8583a72af07a75c2d1216b7 モジュール:Category handler/config 828 31 65 2016-09-04T14:14:09Z srw>Ochaochaocha3 0 1版 をインポートしました Scribunto text/plain -------------------------------------------------------------------------------- -- [[Module:Category handler]] configuration data -- -- Language-specific parameter names and values can be set here. -- -- For blacklist config, see [[Module:Category handler/blacklist]]. -- -------------------------------------------------------------------------------- local cfg = {} -- Don't edit this line. -------------------------------------------------------------------------------- -- Start configuration data -- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -- Parameter names -- -- These configuration items specify custom parameter names. -- -- To add one extra name, you can use this format: -- -- -- -- foo = 'parameter name', -- -- -- -- To add multiple names, you can use this format: -- -- -- -- foo = {'parameter name 1', 'parameter name 2', 'parameter name 3'}, -- -------------------------------------------------------------------------------- cfg.parameters = { -- The nocat and categories parameter suppress -- categorisation. They are used with Module:Yesno, and work as follows: -- -- cfg.nocat: -- Result of yesno() Effect -- true Categorisation is suppressed -- false Categorisation is allowed, and -- the blacklist check is skipped -- nil Categorisation is allowed -- -- cfg.categories: -- Result of yesno() Effect -- true Categorisation is allowed, and -- the blacklist check is skipped -- false Categorisation is suppressed -- nil Categorisation is allowed nocat = 'nocat', categories = 'categories', -- The parameter name for the legacy "category2" parameter. This skips the -- blacklist if set to the cfg.category2Yes value, and suppresses -- categorisation if present but equal to anything other than -- cfg.category2Yes or cfg.category2Negative. category2 = 'category2', -- cfg.subpage is the parameter name to specify how to behave on subpages. subpage = 'subpage', -- The parameter for data to return in all namespaces. all = 'all', -- The parameter name for data to return if no data is specified for the -- namespace that is detected. other = 'other', -- The parameter name used to specify a page other than the current page; -- used for testing and demonstration. demopage = 'page', } -------------------------------------------------------------------------------- -- Parameter values -- -- These are set values that can be used with certain parameters. Only one -- -- value can be specified, like this: -- -- -- -- cfg.foo = 'value name' -- -- -------------------------------------------------------------------------------- -- The following settings are used with the cfg.category2 parameter. Setting -- cfg.category2 to cfg.category2Yes skips the blacklist, and if cfg.category2 -- is present but equal to anything other than cfg.category2Yes or -- cfg.category2Negative then it supresses cateogrisation. cfg.category2Yes = 'yes' cfg.category2Negative = '¬' -- The following settings are used with the cfg.subpage parameter. -- cfg.subpageNo is the value to specify to not categorise on subpages; -- cfg.subpageOnly is the value to specify to only categorise on subpages. cfg.subpageNo = 'no' cfg.subpageOnly = 'only' -------------------------------------------------------------------------------- -- Default namespaces -- -- This is a table of namespaces to categorise by default. The keys are the -- -- namespace numbers. -- -------------------------------------------------------------------------------- cfg.defaultNamespaces = { [ 0] = true, -- main [ 6] = true, -- file [ 12] = true, -- help [ 14] = true, -- category [100] = true, -- portal [108] = true, -- book } -------------------------------------------------------------------------------- -- Wrappers -- -- This is a wrapper template or a list of wrapper templates to be passed to -- -- [[Module:Arguments]]. -- -------------------------------------------------------------------------------- cfg.wrappers = 'Template:Category handler' -------------------------------------------------------------------------------- -- End configuration data -- -------------------------------------------------------------------------------- return cfg -- Don't edit this line. 373cd107b13a5b00e6a1b7e66a749f12502c849d モジュール:Category handler/data 828 32 67 2016-09-04T14:14:10Z srw>Ochaochaocha3 0 1版 をインポートしました Scribunto text/plain -- This module assembles data to be passed to [[Module:Category handler]] using -- mw.loadData. This includes the configuration data and whether the current -- page matches the title blacklist. local data = require('Module:Category handler/config') local mShared = require('Module:Category handler/shared') local blacklist = require('Module:Category handler/blacklist') local title = mw.title.getCurrentTitle() data.currentTitleMatchesBlacklist = mShared.matchesBlacklist( title.prefixedText, blacklist ) data.currentTitleNamespaceParameters = mShared.getNamespaceParameters( title, mShared.getParamMappings() ) return data abbc68048ff698e88dda06b64ecf384bbf583120 モジュール:Category handler/shared 828 33 69 2016-09-04T14:14:11Z srw>Ochaochaocha3 0 1版 をインポートしました Scribunto text/plain -- This module contains shared functions used by [[Module:Category handler]] -- and its submodules. local p = {} function p.matchesBlacklist(page, blacklist) for i, pattern in ipairs(blacklist) do local match = mw.ustring.match(page, pattern) if match then return true end end return false end function p.getParamMappings(useLoadData) local dataPage = 'Module:Namespace detect/data' if useLoadData then return mw.loadData(dataPage).mappings else return require(dataPage).mappings end end function p.getNamespaceParameters(titleObj, mappings) -- We don't use title.nsText for the namespace name because it adds -- underscores. local mappingsKey if titleObj.isTalkPage then mappingsKey = 'talk' else mappingsKey = mw.site.namespaces[titleObj.namespace].name end mappingsKey = mw.ustring.lower(mappingsKey) return mappings[mappingsKey] or {} end return p d2d5de1a031e6ce97c242cbfa8afe7a92cb9eca5 モジュール:Documentation 828 34 71 2016-09-04T14:14:11Z srw>Ochaochaocha3 0 1版 をインポートしました Scribunto text/plain -- This module implements {{documentation}}. -- Get required modules. local getArgs = require('Module:Arguments').getArgs local messageBox = require('Module:Message box') -- Get the config table. local cfg = mw.loadData('Module:Documentation/config') local p = {} -- Often-used functions. local ugsub = mw.ustring.gsub ---------------------------------------------------------------------------- -- Helper functions -- -- These are defined as local functions, but are made available in the p -- table for testing purposes. ---------------------------------------------------------------------------- local function message(cfgKey, valArray, expectType) --[[ -- Gets a message from the cfg table and formats it if appropriate. -- The function raises an error if the value from the cfg table is not -- of the type expectType. The default type for expectType is 'string'. -- If the table valArray is present, strings such as $1, $2 etc. in the -- message are substituted with values from the table keys [1], [2] etc. -- For example, if the message "foo-message" had the value 'Foo $2 bar $1.', -- message('foo-message', {'baz', 'qux'}) would return "Foo qux bar baz." --]] local msg = cfg[cfgKey] expectType = expectType or 'string' if type(msg) ~= expectType then error('メッセージ: メッセージCFGの入力エラー。' .. cfgKey .. ' (' .. expectType .. ' expected, got ' .. type(msg) .. ')', 2) end if not valArray then return msg end local function getMessageVal(match) match = tonumber(match) return valArray[match] or error('メッセージ: メッセージCFGにおいて$' .. match .. 'キーへの値の入力が必要です。' .. cfgKey, 4) end local ret = ugsub(msg, '$([1-9][0-9]*)', getMessageVal) return ret end p.message = message local function makeWikilink(page, display) if display then return mw.ustring.format('[[%s|%s]]', page, display) else return mw.ustring.format('[[%s]]', page) end end p.makeWikilink = makeWikilink local function makeCategoryLink(cat, sort) local catns = mw.site.namespaces[14].name return makeWikilink(catns .. ':' .. cat, sort) end p.makeCategoryLink = makeCategoryLink local function makeUrlLink(url, display) return mw.ustring.format('[%s %s]', url, display) end p.makeUrlLink = makeUrlLink local function makeToolbar(...) local ret = {} local lim = select('#', ...) if lim < 1 then return nil end for i = 1, lim do ret[#ret + 1] = select(i, ...) end return '<small style="font-style: normal;">(' .. table.concat(ret, ' &#124; ') .. ')</small>' end p.makeToolbar = makeToolbar ---------------------------------------------------------------------------- -- Argument processing ---------------------------------------------------------------------------- local function makeInvokeFunc(funcName) return function (frame) local args = getArgs(frame, { valueFunc = function (key, value) if type(value) == 'string' then value = value:match('^%s*(.-)%s*$') -- Remove whitespace. if key == 'heading' or value ~= '' then return value else return nil end else return value end end }) return p[funcName](args) end end ---------------------------------------------------------------------------- -- Main function ---------------------------------------------------------------------------- p.main = makeInvokeFunc('_main') function p._main(args) --[[ -- This function defines logic flow for the module. -- @args - table of arguments passed by the user -- -- Messages: -- 'main-div-id' --> 'template-documentation' -- 'main-div-classes' --> 'template-documentation iezoomfix' --]] local env = p.getEnvironment(args) local root = mw.html.create() root -- :wikitext(p.protectionTemplate(env)) :wikitext(p.sandboxNotice(args, env)) -- This div tag is from {{documentation/start box}}, but moving it here -- so that we don't have to worry about unclosed tags. :tag('div') :attr('id', message('main-div-id')) :addClass(message('main-div-classes')) :newline() :wikitext(p._startBox(args, env)) :wikitext(p._content(args, env)) :css('background-color', '#ecfcf4') :css('border', '1px solid #aaa') :css('padding', '1em') :css('margin', '1em 0 0 0') :css('clear', 'both') :tag('div') :css('clear', 'both') -- So right or left floating items don't stick out of the doc box. :newline() :done() :done() :wikitext(p._endBox(args, env)) :wikitext(p.addTrackingCategories(env)) return tostring(root) end ---------------------------------------------------------------------------- -- Environment settings ---------------------------------------------------------------------------- function p.getEnvironment(args) --[[ -- Returns a table with information about the environment, including title objects and other namespace- or -- path-related data. -- @args - table of arguments passed by the user -- -- Title objects include: -- env.title - the page we are making documentation for (usually the current title) -- env.templateTitle - the template (or module, file, etc.) -- env.docTitle - the /doc subpage. -- env.sandboxTitle - the /sandbox subpage. -- env.testcasesTitle - the /testcases subpage. -- env.printTitle - the print version of the template, located at the /Print subpage. -- -- Data includes: -- env.protectionLevels - the protection levels table of the title object. -- env.subjectSpace - the number of the title's subject namespace. -- env.docSpace - the number of the namespace the title puts its documentation in. -- env.docpageBase - the text of the base page of the /doc, /sandbox and /testcases pages, with namespace. -- env.compareUrl - URL of the Special:ComparePages page comparing the sandbox with the template. -- -- All table lookups are passed through pcall so that errors are caught. If an error occurs, the value -- returned will be nil. --]] local env, envFuncs = {}, {} -- Set up the metatable. If triggered we call the corresponding function in the envFuncs table. The value -- returned by that function is memoized in the env table so that we don't call any of the functions -- more than once. (Nils won't be memoized.) setmetatable(env, { __index = function (t, key) local envFunc = envFuncs[key] if envFunc then local success, val = pcall(envFunc) if success then env[key] = val -- Memoise the value. return val end end return nil end }) function envFuncs.title() -- The title object for the current page, or a test page passed with args.page. local title local titleArg = args.page if titleArg then title = mw.title.new(titleArg) else title = mw.title.getCurrentTitle() end return title end function envFuncs.templateTitle() --[[ -- The template (or module, etc.) title object. -- Messages: -- 'sandbox-subpage' --> 'sandbox' -- 'testcases-subpage' --> 'testcases' --]] local subjectSpace = env.subjectSpace local title = env.title local subpage = title.subpageText if subpage == message('sandbox-subpage') or subpage == message('testcases-subpage') then return mw.title.makeTitle(subjectSpace, title.baseText) else return mw.title.makeTitle(subjectSpace, title.text) end end function envFuncs.docTitle() --[[ -- Title object of the /doc subpage. -- Messages: -- 'doc-subpage' --> 'doc' --]] local title = env.title local docname = args[1] -- User-specified doc page. local docpage if docname then docpage = docname else docpage = env.docpageBase .. '/' .. message('doc-subpage') end return mw.title.new(docpage) end function envFuncs.sandboxTitle() --[[ -- Title object for the /sandbox subpage. -- Messages: -- 'sandbox-subpage' --> 'sandbox' --]] return mw.title.new(env.docpageBase .. '/' .. message('sandbox-subpage')) end function envFuncs.testcasesTitle() --[[ -- Title object for the /testcases subpage. -- Messages: -- 'testcases-subpage' --> 'testcases' --]] return mw.title.new(env.docpageBase .. '/' .. message('testcases-subpage')) end function envFuncs.printTitle() --[[ -- Title object for the /Print subpage. -- Messages: -- 'print-subpage' --> 'Print' --]] return env.templateTitle:subPageTitle(message('print-subpage')) end -- function envFuncs.protectionLevels() -- The protection levels table of the title object. -- return env.title.protectionLevels -- end function envFuncs.subjectSpace() -- The subject namespace number. return mw.site.namespaces[env.title.namespace].subject.id end function envFuncs.docSpace() -- The documentation namespace number. For most namespaces this is the same as the -- subject namespace. However, pages in the Article, File, MediaWiki or Category -- namespaces must have their /doc, /sandbox and /testcases pages in talk space. local subjectSpace = env.subjectSpace if subjectSpace == 0 or subjectSpace == 6 or subjectSpace == 8 or subjectSpace == 14 then return subjectSpace + 1 else return subjectSpace end end function envFuncs.docpageBase() -- The base page of the /doc, /sandbox, and /testcases subpages. -- For some namespaces this is the talk page, rather than the template page. local templateTitle = env.templateTitle local docSpace = env.docSpace local docSpaceText = mw.site.namespaces[docSpace].name -- Assemble the link. docSpace is never the main namespace, so we can hardcode the colon. return docSpaceText .. ':' .. templateTitle.text end function envFuncs.compareUrl() -- Diff link between the sandbox and the main template using [[Special:ComparePages]]. local templateTitle = env.templateTitle local sandboxTitle = env.sandboxTitle if templateTitle.exists and sandboxTitle.exists then local compareUrl = mw.uri.fullUrl( 'Special:ComparePages', {page1 = templateTitle.prefixedText, page2 = sandboxTitle.prefixedText} ) return tostring(compareUrl) else return nil end end return env end ---------------------------------------------------------------------------- -- Auxiliary templates ---------------------------------------------------------------------------- function p.sandboxNotice(args, env) --[=[ -- Generates a sandbox notice for display above sandbox pages. -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- -- Messages: -- 'sandbox-notice-image' --> '[[Image:Sandbox.svg|50px|alt=|link=]]' -- 'sandbox-notice-blurb' --> 'This is the $1 for $2.' -- 'sandbox-notice-diff-blurb' --> 'This is the $1 for $2 ($3).' -- 'sandbox-notice-pagetype-template' --> '[[Wikipedia:Template test cases|template sandbox]] page' -- 'sandbox-notice-pagetype-module' --> '[[Wikipedia:Template test cases|module sandbox]] page' -- 'sandbox-notice-pagetype-other' --> 'sandbox page' -- 'sandbox-notice-compare-link-display' --> 'diff' -- 'sandbox-notice-testcases-blurb' --> 'See also the companion subpage for $1.' -- 'sandbox-notice-testcases-link-display' --> 'test cases' -- 'sandbox-category' --> 'Template sandboxes' --]=] local title = env.title local sandboxTitle = env.sandboxTitle local templateTitle = env.templateTitle local subjectSpace = env.subjectSpace if not (subjectSpace and title and sandboxTitle and templateTitle and mw.title.equals(title, sandboxTitle)) then return nil end -- Build the table of arguments to pass to {{ombox}}. We need just two fields, "image" and "text". local omargs = {} omargs.image = message('sandbox-notice-image') -- Get the text. We start with the opening blurb, which is something like -- "This is the template sandbox for [[Template:Foo]] (diff)." local text = '' local pagetype if subjectSpace == 10 then pagetype = message('sandbox-notice-pagetype-template') elseif subjectSpace == 828 then pagetype = message('sandbox-notice-pagetype-module') else pagetype = message('sandbox-notice-pagetype-other') end local templateLink = makeWikilink(templateTitle.prefixedText) local compareUrl = env.compareUrl if compareUrl then local compareDisplay = message('sandbox-notice-compare-link-display') local compareLink = makeUrlLink(compareUrl, compareDisplay) text = text .. message('sandbox-notice-diff-blurb', {pagetype, templateLink, compareLink}) else text = text .. message('sandbox-notice-blurb', {pagetype, templateLink}) end -- Get the test cases page blurb if the page exists. This is something like -- "See also the companion subpage for [[Template:Foo/testcases|test cases]]." local testcasesTitle = env.testcasesTitle if testcasesTitle and testcasesTitle.exists then if testcasesTitle.namespace == mw.site.namespaces.Module.id then local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display') local testcasesRunLinkDisplay = message('sandbox-notice-testcases-run-link-display') local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay) local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay) text = text .. '<br />' .. message('sandbox-notice-testcases-run-blurb', {testcasesLink, testcasesRunLink}) else local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display') local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay) text = text .. '<br />' .. message('sandbox-notice-testcases-blurb', {testcasesLink}) end end -- Add the sandbox to the sandbox category. text = text .. makeCategoryLink(message('sandbox-category')) omargs.text = text local ret = '<div style="clear: both;"></div>' ret = ret .. messageBox.main('ombox', omargs) return ret end -- function p.protectionTemplate(env) -- Generates the padlock icon in the top right. -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- Messages: -- 'protection-template' --> 'pp-template' -- 'protection-template-args' --> {docusage = 'yes'} -- local protectionLevels, mProtectionBanner -- local title = env.title -- protectionLevels = env.protectionLevels -- if not protectionLevels then -- return nil -- end -- local editProt = protectionLevels.edit and protectionLevels.edit[1] -- local moveProt = protectionLevels.move and protectionLevels.move[1] -- if editProt then -- The page is edit-protected. -- mProtectionBanner = require('Module:Protection banner') -- local reason = message('protection-reason-edit') -- return mProtectionBanner._main{reason, small = true} -- elseif moveProt and moveProt ~= 'autoconfirmed' then -- The page is move-protected but not edit-protected. Exclude move -- protection with the level "autoconfirmed", as this is equivalent to -- no move protection at all. -- mProtectionBanner = require('Module:Protection banner') -- return mProtectionBanner._main{action = 'move', small = true} -- else -- return nil -- end -- end ---------------------------------------------------------------------------- -- Start box ---------------------------------------------------------------------------- p.startBox = makeInvokeFunc('_startBox') function p._startBox(args, env) --[[ -- This function generates the start box. -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- -- The actual work is done by p.makeStartBoxLinksData and p.renderStartBoxLinks which make -- the [view] [edit] [history] [purge] links, and by p.makeStartBoxData and p.renderStartBox -- which generate the box HTML. --]] env = env or p.getEnvironment(args) local links local content = args.content if not content then -- No need to include the links if the documentation is on the template page itself. local linksData = p.makeStartBoxLinksData(args, env) if linksData then links = p.renderStartBoxLinks(linksData) end end -- Generate the start box html. local data = p.makeStartBoxData(args, env, links) if data then return p.renderStartBox(data) else -- User specified no heading. return nil end end function p.makeStartBoxLinksData(args, env) --[[ -- Does initial processing of data to make the [view] [edit] [history] [purge] links. -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- -- Messages: -- 'view-link-display' --> 'view' -- 'edit-link-display' --> 'edit' -- 'history-link-display' --> 'history' -- 'purge-link-display' --> 'purge' -- 'file-docpage-preload' --> 'Template:Documentation/preload-filespace' -- 'module-preload' --> 'Template:Documentation/preload-module-doc' -- 'docpage-preload' --> 'Template:Documentation/preload' -- 'create-link-display' --> 'create' --]] local subjectSpace = env.subjectSpace local title = env.title local docTitle = env.docTitle if not title or not docTitle then return nil end local data = {} data.title = title data.docTitle = docTitle -- View, display, edit, and purge links if /doc exists. data.viewLinkDisplay = message('view-link-display') data.editLinkDisplay = message('edit-link-display') data.historyLinkDisplay = message('history-link-display') data.purgeLinkDisplay = message('purge-link-display') -- Create link if /doc doesn't exist. local preload = args.preload if not preload then if subjectSpace == 6 then -- File namespace preload = message('file-docpage-preload') elseif subjectSpace == 828 then -- Module namespace preload = message('module-preload') else preload = message('docpage-preload') end end data.preload = preload data.createLinkDisplay = message('create-link-display') return data end function p.renderStartBoxLinks(data) --[[ -- Generates the [view][edit][history][purge] or [create] links from the data table. -- @data - a table of data generated by p.makeStartBoxLinksData --]] local function escapeBrackets(s) -- Escapes square brackets with HTML entities. s = s:gsub('%[', '&#91;') -- Replace square brackets with HTML entities. s = s:gsub('%]', '&#93;') return s end local ret local docTitle = data.docTitle local title = data.title if docTitle.exists then local viewLink = makeWikilink(docTitle.prefixedText, data.viewLinkDisplay) local editLink = makeUrlLink(docTitle:fullUrl{action = 'edit'}, data.editLinkDisplay) local historyLink = makeUrlLink(docTitle:fullUrl{action = 'history'}, data.historyLinkDisplay) local purgeLink = makeUrlLink(title:fullUrl{action = 'purge'}, data.purgeLinkDisplay) ret = '[%s] [%s] [%s] [%s]' ret = escapeBrackets(ret) ret = mw.ustring.format(ret, viewLink, editLink, historyLink, purgeLink) else local createLink = makeUrlLink(docTitle:fullUrl{action = 'edit', preload = data.preload}, data.createLinkDisplay) ret = '[%s]' ret = escapeBrackets(ret) ret = mw.ustring.format(ret, createLink) end return ret end function p.makeStartBoxData(args, env, links) --[=[ -- Does initial processing of data to pass to the start-box render function, p.renderStartBox. -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- @links - a string containing the [view][edit][history][purge] links - could be nil if there's an error. -- -- Messages: -- 'documentation-icon-wikitext' --> '[[File:Test Template Info-Icon - Version (2).svg|50px|link=|alt=]]' -- 'template-namespace-heading' --> 'Template documentation' -- 'module-namespace-heading' --> 'Module documentation' -- 'file-namespace-heading' --> 'Summary' -- 'other-namespaces-heading' --> 'Documentation' -- 'start-box-linkclasses' --> 'mw-editsection-like plainlinks' -- 'start-box-link-id' --> 'doc_editlinks' -- 'testcases-create-link-display' --> 'create' --]=] local subjectSpace = env.subjectSpace if not subjectSpace then -- Default to an "other namespaces" namespace, so that we get at least some output -- if an error occurs. subjectSpace = 2 end local data = {} -- Heading local heading = args.heading -- Blank values are not removed. if heading == '' then -- Don't display the start box if the heading arg is defined but blank. return nil end if heading then data.heading = heading elseif subjectSpace == 10 then -- Template namespace data.heading = message('documentation-icon-wikitext') .. ' ' .. message('template-namespace-heading') elseif subjectSpace == 828 then -- Module namespace data.heading = message('documentation-icon-wikitext') .. ' ' .. message('module-namespace-heading') elseif subjectSpace == 6 then -- File namespace data.heading = message('file-namespace-heading') else data.heading = message('other-namespaces-heading') end -- Heading CSS local headingStyle = args['heading-style'] if headingStyle then data.headingStyleText = headingStyle elseif subjectSpace == 10 then -- We are in the template or template talk namespaces. data.headingFontWeight = 'bold' data.headingFontSize = '125%' else data.headingFontSize = '150%' end -- Data for the [view][edit][history][purge] or [create] links. if links then data.linksClass = message('start-box-linkclasses') data.linksId = message('start-box-link-id') data.links = links end return data end function p.renderStartBox(data) -- Renders the start box html. -- @data - a table of data generated by p.makeStartBoxData. local sbox = mw.html.create('div') sbox :css('padding-bottom', '3px') :css('border-bottom', '1px solid #aaa') :css('margin-bottom', '1ex') :newline() :tag('span') :cssText(data.headingStyleText) :css('font-weight', data.headingFontWeight) :css('font-size', data.headingFontSize) :wikitext(data.heading) local links = data.links if links then sbox:tag('span') :addClass(data.linksClass) :attr('id', data.linksId) :wikitext(links) end return tostring(sbox) end ---------------------------------------------------------------------------- -- Documentation content ---------------------------------------------------------------------------- p.content = makeInvokeFunc('_content') function p._content(args, env) -- Displays the documentation contents -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment env = env or p.getEnvironment(args) local docTitle = env.docTitle local content = args.content if not content and docTitle and docTitle.exists then content = args._content or mw.getCurrentFrame():expandTemplate{title = docTitle.prefixedText} end -- The line breaks below are necessary so that "=== Headings ===" at the start and end -- of docs are interpreted correctly. return '\n' .. (content or '') .. '\n' end p.contentTitle = makeInvokeFunc('_contentTitle') function p._contentTitle(args, env) env = env or p.getEnvironment(args) local docTitle = env.docTitle if not args.content and docTitle and docTitle.exists then return docTitle.prefixedText else return '' end end ---------------------------------------------------------------------------- -- End box ---------------------------------------------------------------------------- p.endBox = makeInvokeFunc('_endBox') function p._endBox(args, env) --[=[ -- This function generates the end box (also known as the link box). -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- -- Messages: -- 'fmbox-id' --> 'documentation-meta-data' -- 'fmbox-style' --> 'background-color: #ecfcf4' -- 'fmbox-textstyle' --> 'font-style: italic' -- -- The HTML is generated by the {{fmbox}} template, courtesy of [[Module:Message box]]. --]=] -- Get environment data. env = env or p.getEnvironment(args) local subjectSpace = env.subjectSpace local docTitle = env.docTitle if not subjectSpace or not docTitle then return nil end -- Check whether we should output the end box at all. Add the end -- box by default if the documentation exists or if we are in the -- user, module or template namespaces. local linkBox = args['link box'] if linkBox == 'off' or not ( docTitle.exists or subjectSpace == 2 or subjectSpace == 828 or subjectSpace == 10 ) then return nil end -- Assemble the arguments for {{fmbox}}. local fmargs = {} fmargs.id = message('fmbox-id') -- Sets 'documentation-meta-data' fmargs.image = 'none' fmargs.style = message('fmbox-style') -- Sets 'background-color: #ecfcf4' fmargs.textstyle = message('fmbox-textstyle') -- 'font-style: italic;' -- Assemble the fmbox text field. local text = '' if linkBox then text = text .. linkBox else text = text .. (p.makeDocPageBlurb(args, env) or '') -- "This documentation is transcluded from [[Foo]]." if subjectSpace == 2 or subjectSpace == 10 or subjectSpace == 828 then -- We are in the user, template or module namespaces. -- Add sandbox and testcases links. -- "Editors can experiment in this template's sandbox and testcases pages." text = text .. (p.makeExperimentBlurb(args, env) or '') text = text .. '<br />' if not args.content and not args[1] then -- "Please add categories to the /doc subpage." -- Don't show this message with inline docs or with an explicitly specified doc page, -- as then it is unclear where to add the categories. text = text .. (p.makeCategoriesBlurb(args, env) or '') end text = text .. ' ' .. (p.makeSubpagesBlurb(args, env) or '') --"Subpages of this template" local printBlurb = p.makePrintBlurb(args, env) -- Two-line blurb about print versions of templates. if printBlurb then text = text .. '<br />' .. printBlurb end end end fmargs.text = text return messageBox.main('fmbox', fmargs) end function p.makeDocPageBlurb(args, env) --[=[ -- Makes the blurb "This documentation is transcluded from [[Template:Foo]] (edit, history)". -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- -- Messages: -- 'edit-link-display' --> 'edit' -- 'history-link-display' --> 'history' -- 'transcluded-from-blurb' --> -- 'The above [[Wikipedia:Template documentation|documentation]] -- is [[Wikipedia:Transclusion|transcluded]] from $1.' -- 'module-preload' --> 'Template:Documentation/preload-module-doc' -- 'create-link-display' --> 'create' -- 'create-module-doc-blurb' --> -- 'You might want to $1 a documentation page for this [[Wikipedia:Lua|Scribunto module]].' --]=] local docTitle = env.docTitle if not docTitle then return nil end local ret if docTitle.exists then -- /doc exists; link to it. local docLink = makeWikilink(docTitle.prefixedText) local editUrl = docTitle:fullUrl{action = 'edit'} local editDisplay = message('edit-link-display') local editLink = makeUrlLink(editUrl, editDisplay) local historyUrl = docTitle:fullUrl{action = 'history'} local historyDisplay = message('history-link-display') local historyLink = makeUrlLink(historyUrl, historyDisplay) ret = message('transcluded-from-blurb', {docLink}) .. ' ' .. makeToolbar(editLink, historyLink) .. '<br />' elseif env.subjectSpace == 828 then -- /doc does not exist; ask to create it. local createUrl = docTitle:fullUrl{action = 'edit', preload = message('module-preload')} local createDisplay = message('create-link-display') local createLink = makeUrlLink(createUrl, createDisplay) ret = message('create-module-doc-blurb', {createLink}) .. '<br />' end return ret end function p.makeExperimentBlurb(args, env) --[[ -- Renders the text "Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages." -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- -- Messages: -- 'sandbox-link-display' --> 'sandbox' -- 'sandbox-edit-link-display' --> 'edit' -- 'compare-link-display' --> 'diff' -- 'module-sandbox-preload' --> 'Template:Documentation/preload-module-sandbox' -- 'template-sandbox-preload' --> 'Template:Documentation/preload-sandbox' -- 'sandbox-create-link-display' --> 'create' -- 'mirror-edit-summary' --> 'Create sandbox version of $1' -- 'mirror-link-display' --> 'mirror' -- 'mirror-link-preload' --> 'Template:Documentation/mirror' -- 'sandbox-link-display' --> 'sandbox' -- 'testcases-link-display' --> 'testcases' -- 'testcases-edit-link-display'--> 'edit' -- 'template-sandbox-preload' --> 'Template:Documentation/preload-sandbox' -- 'testcases-create-link-display' --> 'create' -- 'testcases-link-display' --> 'testcases' -- 'testcases-edit-link-display' --> 'edit' -- 'module-testcases-preload' --> 'Template:Documentation/preload-module-testcases' -- 'template-testcases-preload' --> 'Template:Documentation/preload-testcases' -- 'experiment-blurb-module' --> 'Editors can experiment in this module's $1 and $2 pages.' -- 'experiment-blurb-template' --> 'Editors can experiment in this template's $1 and $2 pages.' --]] local subjectSpace = env.subjectSpace local templateTitle = env.templateTitle local sandboxTitle = env.sandboxTitle local testcasesTitle = env.testcasesTitle local templatePage = templateTitle.prefixedText if not subjectSpace or not templateTitle or not sandboxTitle or not testcasesTitle then return nil end -- Make links. local sandboxLinks, testcasesLinks if sandboxTitle.exists then local sandboxPage = sandboxTitle.prefixedText local sandboxDisplay = message('sandbox-link-display') local sandboxLink = makeWikilink(sandboxPage, sandboxDisplay) local sandboxEditUrl = sandboxTitle:fullUrl{action = 'edit'} local sandboxEditDisplay = message('sandbox-edit-link-display') local sandboxEditLink = makeUrlLink(sandboxEditUrl, sandboxEditDisplay) local compareUrl = env.compareUrl local compareLink if compareUrl then local compareDisplay = message('compare-link-display') compareLink = makeUrlLink(compareUrl, compareDisplay) end sandboxLinks = sandboxLink .. ' ' .. makeToolbar(sandboxEditLink, compareLink) else local sandboxPreload if subjectSpace == 828 then sandboxPreload = message('module-sandbox-preload') else sandboxPreload = message('template-sandbox-preload') end local sandboxCreateUrl = sandboxTitle:fullUrl{action = 'edit', preload = sandboxPreload} local sandboxCreateDisplay = message('sandbox-create-link-display') local sandboxCreateLink = makeUrlLink(sandboxCreateUrl, sandboxCreateDisplay) local mirrorSummary = message('mirror-edit-summary', {makeWikilink(templatePage)}) local mirrorPreload = message('mirror-link-preload') local mirrorUrl = sandboxTitle:fullUrl{action = 'edit', preload = mirrorPreload, summary = mirrorSummary} if subjectSpace == 828 then mirrorUrl = sandboxTitle:fullUrl{action = 'edit', preload = templateTitle.prefixedText, summary = mirrorSummary} end local mirrorDisplay = message('mirror-link-display') local mirrorLink = makeUrlLink(mirrorUrl, mirrorDisplay) sandboxLinks = message('sandbox-link-display') .. ' ' .. makeToolbar(sandboxCreateLink, mirrorLink) end if testcasesTitle.exists then local testcasesPage = testcasesTitle.prefixedText local testcasesDisplay = message('testcases-link-display') local testcasesLink = makeWikilink(testcasesPage, testcasesDisplay) local testcasesEditUrl = testcasesTitle:fullUrl{action = 'edit'} local testcasesEditDisplay = message('testcases-edit-link-display') local testcasesEditLink = makeUrlLink(testcasesEditUrl, testcasesEditDisplay) -- for Modules, add testcases run link if exists if subjectSpace == 828 and testcasesTitle.talkPageTitle and testcasesTitle.talkPageTitle.exists then local testcasesRunLinkDisplay = message('testcases-run-link-display') local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay) testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink, testcasesRunLink) else testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink) end else local testcasesPreload if subjectSpace == 828 then testcasesPreload = message('module-testcases-preload') else testcasesPreload = message('template-testcases-preload') end local testcasesCreateUrl = testcasesTitle:fullUrl{action = 'edit', preload = testcasesPreload} local testcasesCreateDisplay = message('testcases-create-link-display') local testcasesCreateLink = makeUrlLink(testcasesCreateUrl, testcasesCreateDisplay) testcasesLinks = message('testcases-link-display') .. ' ' .. makeToolbar(testcasesCreateLink) end local messageName if subjectSpace == 828 then messageName = 'experiment-blurb-module' else messageName = 'experiment-blurb-template' end return message(messageName, {sandboxLinks, testcasesLinks}) end function p.makeCategoriesBlurb(args, env) --[[ -- Generates the text "Please add categories to the /doc subpage." -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- Messages: -- 'doc-link-display' --> '/doc' -- 'add-categories-blurb' --> 'Please add categories to the $1 subpage.' --]] local docTitle = env.docTitle if not docTitle then return nil end local docPathLink = makeWikilink(docTitle.prefixedText, message('doc-link-display')) return message('add-categories-blurb', {docPathLink}) end function p.makeSubpagesBlurb(args, env) --[[ -- Generates the "Subpages of this template" link. -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- Messages: -- 'template-pagetype' --> 'template' -- 'module-pagetype' --> 'module' -- 'default-pagetype' --> 'page' -- 'subpages-link-display' --> 'Subpages of this $1' --]] local subjectSpace = env.subjectSpace local templateTitle = env.templateTitle if not subjectSpace or not templateTitle then return nil end local pagetype if subjectSpace == 10 then pagetype = message('template-pagetype') elseif subjectSpace == 828 then pagetype = message('module-pagetype') else pagetype = message('default-pagetype') end local subpagesLink = makeWikilink( 'Special:PrefixIndex/' .. templateTitle.prefixedText .. '/', message('subpages-link-display', {pagetype}) ) return message('subpages-blurb', {subpagesLink}) end function p.makePrintBlurb(args, env) --[=[ -- Generates the blurb displayed when there is a print version of the template available. -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- -- Messages: -- 'print-link-display' --> '/Print' -- 'print-blurb' --> 'A [[Help:Books/for experts#Improving the book layout|print version]]' -- .. ' of this template exists at $1.' -- .. ' If you make a change to this template, please update the print version as well.' -- 'display-print-category' --> true -- 'print-category' --> 'Templates with print versions' --]=] local printTitle = env.printTitle if not printTitle then return nil end local ret if printTitle.exists then local printLink = makeWikilink(printTitle.prefixedText, message('print-link-display')) ret = message('print-blurb', {printLink}) local displayPrintCategory = message('display-print-category', nil, 'boolean') if displayPrintCategory then ret = ret .. makeCategoryLink(message('print-category')) end end return ret end ---------------------------------------------------------------------------- -- Tracking categories ---------------------------------------------------------------------------- function p.addTrackingCategories(env) --[[ -- Check if {{documentation}} is transcluded on a /doc or /testcases page. -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- Messages: -- 'display-strange-usage-category' --> true -- 'doc-subpage' --> 'doc' -- 'testcases-subpage' --> 'testcases' -- 'strange-usage-category' --> 'Wikipedia pages with strange ((documentation)) usage' -- -- /testcases pages in the module namespace are not categorised, as they may have -- {{documentation}} transcluded automatically. --]] local title = env.title local subjectSpace = env.subjectSpace if not title or not subjectSpace then return nil end local subpage = title.subpageText local ret = '' if message('display-strange-usage-category', nil, 'boolean') and ( subpage == message('doc-subpage') or subjectSpace ~= 828 and subpage == message('testcases-subpage') ) then ret = ret .. makeCategoryLink(message('strange-usage-category')) end return ret end return p 5526f3e983324ad73f5b8865471ba81108a2198c モジュール:Documentation/config 828 35 73 2016-09-04T14:14:12Z srw>Ochaochaocha3 0 1版 をインポートしました Scribunto text/plain ---------------------------------------------------------------------------------------------------- -- -- Configuration for Module:Documentation -- -- Here you can set the values of the parameters and messages used in Module:Documentation to -- localise it to your wiki and your language. Unless specified otherwise, values given here -- should be string values. ---------------------------------------------------------------------------------------------------- local cfg = {} -- Do not edit this line. ---------------------------------------------------------------------------------------------------- -- Protection template configuration ---------------------------------------------------------------------------------------------------- -- cfg['protection-reason-edit'] -- The protection reason for edit-protected templates to pass to -- [[Module:Protection banner]]. -- cfg['protection-reason-edit'] = 'template' --[[ ---------------------------------------------------------------------------------------------------- -- Sandbox notice configuration -- -- On sandbox pages the module can display a template notifying users that the current page is a -- sandbox, and the location of test cases pages, etc. The module decides whether the page is a -- sandbox or not based on the value of cfg['sandbox-subpage']. The following settings configure the -- messages that the notices contains. ---------------------------------------------------------------------------------------------------- --]] -- cfg['sandbox-notice-image'] -- The image displayed in the sandbox notice. cfg['sandbox-notice-image'] = '[[Image:Sandbox.svg|50px|alt=|link=]]' --[[ -- cfg['sandbox-notice-pagetype-template'] -- cfg['sandbox-notice-pagetype-module'] -- cfg['sandbox-notice-pagetype-other'] -- The page type of the sandbox page. The message that is displayed depends on the current subject -- namespace. This message is used in either cfg['sandbox-notice-blurb'] or -- cfg['sandbox-notice-diff-blurb']. --]] cfg['sandbox-notice-pagetype-template'] = '[[Wikipedia:テンプレートのサンドボックスとテストケース|テンプレート・サンドボックス]]ページ' cfg['sandbox-notice-pagetype-module'] = '[[Wikipedia:テンプレートのサンドボックスとテストケース|モジュール・サンドボックス]]ページ' cfg['sandbox-notice-pagetype-other'] = 'サンドボックス・ページ' --[[ -- cfg['sandbox-notice-blurb'] -- cfg['sandbox-notice-diff-blurb'] -- cfg['sandbox-notice-diff-display'] -- Either cfg['sandbox-notice-blurb'] or cfg['sandbox-notice-diff-blurb'] is the opening sentence -- of the sandbox notice. The latter has a diff link, but the former does not. $1 is the page -- type, which is either cfg['sandbox-notice-pagetype-template'], -- cfg['sandbox-notice-pagetype-module'] or cfg['sandbox-notice-pagetype-other'] depending what -- namespace we are in. $2 is a link to the main template page, and $3 is a diff link between -- the sandbox and the main template. The display value of the diff link is set by -- cfg['sandbox-notice-compare-link-display']. --]] cfg['sandbox-notice-blurb'] = 'これは$2の$1です。' cfg['sandbox-notice-diff-blurb'] = 'これは$2 ($3)の$1です。' cfg['sandbox-notice-compare-link-display'] = '差分' --[[ -- cfg['sandbox-notice-testcases-blurb'] -- cfg['sandbox-notice-testcases-link-display'] -- cfg['sandbox-notice-testcases-run-blurb'] -- cfg['sandbox-notice-testcases-run-link-display'] -- cfg['sandbox-notice-testcases-blurb'] is a sentence notifying the user that there is a test cases page -- corresponding to this sandbox that they can edit. $1 is a link to the test cases page. -- cfg['sandbox-notice-testcases-link-display'] is the display value for that link. -- cfg['sandbox-notice-testcases-run-blurb'] is a sentence notifying the user that there is a test cases page -- corresponding to this sandbox that they can edit, along with a link to run it. $1 is a link to the test -- cases page, and $2 is a link to the page to run it. -- cfg['sandbox-notice-testcases-run-link-display'] is the display value for the link to run the test -- cases. --]] cfg['sandbox-notice-testcases-blurb'] = '対応する$1・サブページもご確認ください。' cfg['sandbox-notice-testcases-link-display'] = 'テストケース' cfg['sandbox-notice-testcases-run-blurb'] = '対応する$1・サブページ ($2) もご確認ください。' cfg['sandbox-notice-testcases-run-link-display'] = '実行' -- cfg['sandbox-category'] -- A category to add to all template sandboxes. cfg['sandbox-category'] = 'テンプレート・サンドボックス' ---------------------------------------------------------------------------------------------------- -- Start box configuration ---------------------------------------------------------------------------------------------------- -- cfg['documentation-icon-wikitext'] -- The wikitext for the icon shown at the top of the template. cfg['documentation-icon-wikitext'] = '[[File:Test Template Info-Icon - Version (2).svg|50px|link=|alt=]]' -- cfg['template-namespace-heading'] -- The heading shown in the template namespace. cfg['template-namespace-heading'] = 'テンプレートの解説' -- cfg['module-namespace-heading'] -- The heading shown in the module namespace. cfg['module-namespace-heading'] = 'モジュールの解説' -- cfg['file-namespace-heading'] -- The heading shown in the file namespace. cfg['file-namespace-heading'] = '要約' -- cfg['other-namespaces-heading'] -- The heading shown in other namespaces. cfg['other-namespaces-heading'] = '解説' -- cfg['view-link-display'] -- The text to display for "view" links. cfg['view-link-display'] = '表示' -- cfg['edit-link-display'] -- The text to display for "edit" links. cfg['edit-link-display'] = '編集' -- cfg['history-link-display'] -- The text to display for "history" links. cfg['history-link-display'] = '履歴' -- cfg['purge-link-display'] -- The text to display for "purge" links. cfg['purge-link-display'] = 'キャッシュを破棄' -- cfg['create-link-display'] -- The text to display for "create" links. cfg['create-link-display'] = '作成' ---------------------------------------------------------------------------------------------------- -- Link box (end box) configuration ---------------------------------------------------------------------------------------------------- -- cfg['transcluded-from-blurb'] -- Notice displayed when the docs are transcluded from another page. $1 is a wikilink to that page. cfg['transcluded-from-blurb'] = 'この[[Help:テンプレートの説明文|解説]]は、$1から[[Help:テンプレート#テンプレートとは|呼び出されて]]います。' --[[ -- cfg['create-module-doc-blurb'] -- Notice displayed in the module namespace when the documentation subpage does not exist. -- $1 is a link to create the documentation page with the preload cfg['module-preload'] and the -- display cfg['create-link-display']. --]] cfg['create-module-doc-blurb'] = 'この[[Wikipedia:Lua|Scribuntoモジュール]]の解説ページを$1することができます。' ---------------------------------------------------------------------------------------------------- -- Experiment blurb configuration ---------------------------------------------------------------------------------------------------- --[[ -- cfg['experiment-blurb-template'] -- cfg['experiment-blurb-module'] -- The experiment blurb is the text inviting editors to experiment in sandbox and test cases pages. -- It is only shown in the template and module namespaces. With the default English settings, it -- might look like this: -- -- Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages. -- -- In this example, "sandbox", "edit", "diff", "testcases", and "edit" would all be links. -- -- There are two versions, cfg['experiment-blurb-template'] and cfg['experiment-blurb-module'], depending -- on what namespace we are in. -- -- Parameters: -- -- $1 is a link to the sandbox page. If the sandbox exists, it is in the following format: -- -- cfg['sandbox-link-display'] (cfg['sandbox-edit-link-display'] | cfg['compare-link-display']) -- -- If the sandbox doesn't exist, it is in the format: -- -- cfg['sandbox-link-display'] (cfg['sandbox-create-link-display'] | cfg['mirror-link-display']) -- -- The link for cfg['sandbox-create-link-display'] link preloads the page with cfg['template-sandbox-preload'] -- or cfg['module-sandbox-preload'], depending on the current namespace. The link for cfg['mirror-link-display'] -- loads a default edit summary of cfg['mirror-edit-summary']. -- -- $2 is a link to the test cases page. If the test cases page exists, it is in the following format: -- -- cfg['testcases-link-display'] (cfg['testcases-edit-link-display'] | cfg['testcases-run-link-display']) -- -- If the test cases page doesn't exist, it is in the format: -- -- cfg['testcases-link-display'] (cfg['testcases-create-link-display']) -- -- If the test cases page doesn't exist, the link for cfg['testcases-create-link-display'] preloads the -- page with cfg['template-testcases-preload'] or cfg['module-testcases-preload'], depending on the current -- namespace. --]] cfg['experiment-blurb-template'] = "編集者は、このテンプレートを$1と$2で試すことができます。([[Wikipedia:テンプレートのサンドボックスとテストケース|解説]])" cfg['experiment-blurb-module'] = "編集者は、このモジュールを$1と$2で試すことができます。([[Wikipedia:テンプレートのサンドボックスとテストケース|解説]])" ---------------------------------------------------------------------------------------------------- -- Sandbox link configuration ---------------------------------------------------------------------------------------------------- -- cfg['sandbox-subpage'] -- The name of the template subpage typically used for sandboxes. cfg['sandbox-subpage'] = 'sandbox' -- cfg['template-sandbox-preload'] -- Preload file for template sandbox pages. cfg['template-sandbox-preload'] = 'Template:Documentation/preload-sandbox' -- cfg['module-sandbox-preload'] -- Preload file for Lua module sandbox pages. cfg['module-sandbox-preload'] = 'Template:Documentation/preload-module-sandbox' -- cfg['sandbox-link-display'] -- The text to display for "sandbox" links. cfg['sandbox-link-display'] = 'サンドボックス' -- cfg['sandbox-edit-link-display'] -- The text to display for sandbox "edit" links. cfg['sandbox-edit-link-display'] = '編集' -- cfg['sandbox-create-link-display'] -- The text to display for sandbox "create" links. cfg['sandbox-create-link-display'] = '作成' -- cfg['compare-link-display'] -- The text to display for "compare" links. cfg['compare-link-display'] = '差分' -- cfg['mirror-edit-summary'] -- The default edit summary to use when a user clicks the "mirror" link. $1 is a wikilink to the -- template page. cfg['mirror-edit-summary'] = '$1のサンドボックスバージョンを作成' -- cfg['mirror-link-display'] -- The text to display for "mirror" links. cfg['mirror-link-display'] = '複製' -- cfg['mirror-link-preload'] -- The page to preload when a user clicks the "mirror" link. cfg['mirror-link-preload'] = 'Template:Documentation/mirror' ---------------------------------------------------------------------------------------------------- -- Test cases link configuration ---------------------------------------------------------------------------------------------------- -- cfg['testcases-subpage'] -- The name of the template subpage typically used for test cases. cfg['testcases-subpage'] = 'testcases' -- cfg['template-testcases-preload'] -- Preload file for template test cases pages. cfg['template-testcases-preload'] = 'Template:Documentation/preload-testcases' -- cfg['module-testcases-preload'] -- Preload file for Lua module test cases pages. cfg['module-testcases-preload'] = 'Template:Documentation/preload-module-testcases' -- cfg['testcases-link-display'] -- The text to display for "testcases" links. cfg['testcases-link-display'] = 'テストケース' -- cfg['testcases-edit-link-display'] -- The text to display for test cases "edit" links. cfg['testcases-edit-link-display'] = '編集' -- cfg['testcases-run-link-display'] -- The text to display for test cases "run" links. cfg['testcases-run-link-display'] = '作動' -- cfg['testcases-create-link-display'] -- The text to display for test cases "create" links. cfg['testcases-create-link-display'] = '作成' ---------------------------------------------------------------------------------------------------- -- Add categories blurb configuration ---------------------------------------------------------------------------------------------------- --[[ -- cfg['add-categories-blurb'] -- Text to direct users to add categories to the /doc subpage. Not used if the "content" or -- "docname fed" arguments are set, as then it is not clear where to add the categories. $1 is a -- link to the /doc subpage with a display value of cfg['doc-link-display']. --]] cfg['add-categories-blurb'] = '$1のサブページにカテゴリを追加してください。' -- cfg['doc-link-display'] -- The text to display when linking to the /doc subpage. cfg['doc-link-display'] = '/doc' ---------------------------------------------------------------------------------------------------- -- Subpages link configuration ---------------------------------------------------------------------------------------------------- --[[ -- cfg['subpages-blurb'] -- The "Subpages of this template" blurb. $1 is a link to the main template's subpages with a -- display value of cfg['subpages-link-display']. In the English version this blurb is simply -- the link followed by a period, and the link display provides the actual text. --]] cfg['subpages-blurb'] = '$1' --[[ -- cfg['subpages-link-display'] -- The text to display for the "subpages of this page" link. $1 is cfg['template-pagetype'], -- cfg['module-pagetype'] or cfg['default-pagetype'], depending on whether the current page is in -- the template namespace, the module namespace, or another namespace. --]] cfg['subpages-link-display'] = 'この$1のサブページ一覧。' -- cfg['template-pagetype'] -- The pagetype to display for template pages. cfg['template-pagetype'] = 'テンプレート' -- cfg['module-pagetype'] -- The pagetype to display for Lua module pages. cfg['module-pagetype'] = 'モジュール' -- cfg['default-pagetype'] -- The pagetype to display for pages other than templates or Lua modules. cfg['default-pagetype'] = 'ページ' ---------------------------------------------------------------------------------------------------- -- Doc link configuration ---------------------------------------------------------------------------------------------------- -- cfg['doc-subpage'] -- The name of the subpage typically used for documentation pages. cfg['doc-subpage'] = 'doc' -- cfg['file-docpage-preload'] -- Preload file for documentation page in the file namespace. cfg['file-docpage-preload'] = 'Template:Documentation/preload-filespace' -- cfg['docpage-preload'] -- Preload file for template documentation pages in all namespaces. cfg['docpage-preload'] = 'Template:Documentation/preload' -- cfg['module-preload'] -- Preload file for Lua module documentation pages. cfg['module-preload'] = 'Template:Documentation/preload-module-doc' ---------------------------------------------------------------------------------------------------- -- Print version configuration ---------------------------------------------------------------------------------------------------- -- cfg['print-subpage'] -- The name of the template subpage used for print versions. cfg['print-subpage'] = 'Print' -- cfg['print-link-display'] -- The text to display when linking to the /Print subpage. cfg['print-link-display'] = '/Print' -- cfg['print-blurb'] -- Text to display if a /Print subpage exists. $1 is a link to the subpage with a display value of cfg['print-link-display']. cfg['print-blurb'] = '$1にこのテンプレートはの[[Help:Books/for experts#Improving the book layout|印刷バージョンがあります]]。' .. 'もしこのテンプレートを更新した時は、印刷バージョンも更新してください。' -- cfg['display-print-category'] -- Set to true to enable output of cfg['print-category'] if a /Print subpage exists. -- This should be a boolean value (either true or false). cfg['display-print-category'] = true -- cfg['print-category'] -- Category to output if cfg['display-print-category'] is set to true, and a /Print subpage exists. cfg['print-category'] = '' ---------------------------------------------------------------------------------------------------- -- HTML and CSS configuration ---------------------------------------------------------------------------------------------------- -- cfg['main-div-id'] -- The "id" attribute of the main HTML "div" tag. cfg['main-div-id'] = 'template-documentation' -- cfg['main-div-classes'] -- The CSS classes added to the main HTML "div" tag. cfg['main-div-classes'] = 'template-documentation iezoomfix' -- cfg['start-box-linkclasses'] -- The CSS classes used for the [view][edit][history] or [create] links in the start box. cfg['start-box-linkclasses'] = 'mw-editsection-like plainlinks' -- cfg['start-box-link-id'] -- The HTML "id" attribute for the links in the start box. cfg['start-box-link-id'] = 'doc_editlinks' ---------------------------------------------------------------------------------------------------- -- {{fmbox}} template configuration ---------------------------------------------------------------------------------------------------- -- cfg['fmbox-id'] -- The id sent to the "id" parameter of the {{fmbox}} template. cfg['fmbox-id'] = 'documentation-meta-data' -- cfg['fmbox-style'] -- The value sent to the style parameter of {{fmbox}}. cfg['fmbox-style'] = 'background-color: #ecfcf4' -- cfg['fmbox-textstyle'] -- The value sent to the "textstyle parameter of {{fmbox}}. cfg['fmbox-textstyle'] = 'font-style: italic' ---------------------------------------------------------------------------------------------------- -- Tracking category configuration ---------------------------------------------------------------------------------------------------- -- cfg['display-strange-usage-category'] -- Set to true to enable output of cfg['strange-usage-category'] if the module is used on a /doc subpage -- or a /testcases subpage. This should be a boolean value (either true or false). cfg['display-strange-usage-category'] = true -- cfg['strange-usage-category'] -- Category to output if cfg['display-strange-usage-category'] is set to true and the module is used on a -- /doc subpage or a /testcases subpage. cfg['strange-usage-category'] = '((documentation))の異常な使用があるページ' --[[ ---------------------------------------------------------------------------------------------------- -- End configuration -- -- Don't edit anything below this line. ---------------------------------------------------------------------------------------------------- --]] return cfg 063e3994fdbad524d528acb6d213f6a9cc3f7580 モジュール:Message box 828 38 79 2016-09-04T14:14:15Z srw>Ochaochaocha3 0 1版 をインポートしました Scribunto text/plain -- This is a meta-module for producing message box templates, including -- {{mbox}}, {{ambox}}, {{imbox}}, {{tmbox}}, {{ombox}}, {{cmbox}} and {{fmbox}}. -- Load necessary modules. require('Module:No globals') local getArgs local categoryHandler = require('Module:Category handler')._main local yesno = require('Module:Yesno') -- Get a language object for formatDate and ucfirst. local lang = mw.language.getContentLanguage() -------------------------------------------------------------------------------- -- Helper functions -------------------------------------------------------------------------------- local function getTitleObject(...) -- Get the title object, passing the function through pcall -- in case we are over the expensive function count limit. local success, title = pcall(mw.title.new, ...) if success then return title end end local function union(t1, t2) -- Returns the union of two arrays. local vals = {} for i, v in ipairs(t1) do vals[v] = true end for i, v in ipairs(t2) do vals[v] = true end local ret = {} for k in pairs(vals) do table.insert(ret, k) end table.sort(ret) return ret end local function getArgNums(args, prefix) local nums = {} for k, v in pairs(args) do local num = mw.ustring.match(tostring(k), '^' .. prefix .. '([1-9]%d*)$') if num then table.insert(nums, tonumber(num)) end end table.sort(nums) return nums end -------------------------------------------------------------------------------- -- Box class definition -------------------------------------------------------------------------------- local MessageBox = {} MessageBox.__index = MessageBox function MessageBox.new(boxType, args, cfg) args = args or {} local obj = {} -- Set the title object and the namespace. obj.title = getTitleObject(args.page) or mw.title.getCurrentTitle() -- Set the config for our box type. obj.cfg = cfg[boxType] if not obj.cfg then local ns = obj.title.namespace -- boxType is "mbox" or invalid input if ns == 0 then obj.cfg = cfg.ambox -- main namespace elseif ns == 6 then obj.cfg = cfg.imbox -- file namespace elseif ns == 14 then obj.cfg = cfg.cmbox -- category namespace else local nsTable = mw.site.namespaces[ns] if nsTable and nsTable.isTalk then obj.cfg = cfg.tmbox -- any talk namespace else obj.cfg = cfg.ombox -- other namespaces or invalid input end end end -- Set the arguments, and remove all blank arguments except for the ones -- listed in cfg.allowBlankParams. do local newArgs = {} for k, v in pairs(args) do if v ~= '' then newArgs[k] = v end end for i, param in ipairs(obj.cfg.allowBlankParams or {}) do newArgs[param] = args[param] end obj.args = newArgs end -- Define internal data structure. obj.categories = {} obj.classes = {} return setmetatable(obj, MessageBox) end function MessageBox:addCat(ns, cat, sort) if not cat then return nil end if sort then cat = string.format('[[Category:%s|%s]]', cat, sort) else cat = string.format('[[Category:%s]]', cat) end self.categories[ns] = self.categories[ns] or {} table.insert(self.categories[ns], cat) end function MessageBox:addClass(class) if not class then return nil end table.insert(self.classes, class) end function MessageBox:setParameters() local args = self.args local cfg = self.cfg -- Get type data. self.type = args.type local typeData = cfg.types[self.type] self.invalidTypeError = cfg.showInvalidTypeError and self.type and not typeData typeData = typeData or cfg.types[cfg.default] self.typeClass = typeData.class self.typeImage = typeData.image -- Find if the box has been wrongly substituted. self.isSubstituted = cfg.substCheck and args.subst == 'SUBST' -- Find whether we are using a small message box. self.isSmall = cfg.allowSmall and ( cfg.smallParam and args.small == cfg.smallParam or not cfg.smallParam and yesno(args.small) ) -- Add attributes, classes and styles. self.id = args.id self:addClass( cfg.usePlainlinksParam and yesno(args.plainlinks or true) and 'plainlinks' ) for _, class in ipairs(cfg.classes or {}) do self:addClass(class) end if self.isSmall then self:addClass(cfg.smallClass or 'mbox-small') end self:addClass(self.typeClass) self:addClass(args.class) self.style = args.style self.attrs = args.attrs -- Set text style. self.textstyle = args.textstyle -- Find if we are on the template page or not. This functionality is only -- used if useCollapsibleTextFields is set, or if both cfg.templateCategory -- and cfg.templateCategoryRequireName are set. self.useCollapsibleTextFields = cfg.useCollapsibleTextFields if self.useCollapsibleTextFields or cfg.templateCategory and cfg.templateCategoryRequireName then self.name = args.name if self.name then local templateName = mw.ustring.match( self.name, '^[tT][eE][mM][pP][lL][aA][tT][eE][%s_]*:[%s_]*(.*)$' ) or self.name templateName = 'Template:' .. templateName self.templateTitle = getTitleObject(templateName) end self.isTemplatePage = self.templateTitle and mw.title.equals(self.title, self.templateTitle) end -- Process data for collapsible text fields. At the moment these are only -- used in {{ambox}}. if self.useCollapsibleTextFields then -- Get the self.issue value. if self.isSmall and args.smalltext then self.issue = args.smalltext else local sect if args.sect == '' then sect = 'This ' .. (cfg.sectionDefault or 'page') elseif type(args.sect) == 'string' then sect = 'This ' .. args.sect end local issue = args.issue issue = type(issue) == 'string' and issue ~= '' and issue or nil local text = args.text text = type(text) == 'string' and text or nil local issues = {} table.insert(issues, sect) table.insert(issues, issue) table.insert(issues, text) self.issue = table.concat(issues, ' ') end -- Get the self.talk value. local talk = args.talk -- Show talk links on the template page or template subpages if the talk -- parameter is blank. if talk == '' and self.templateTitle and ( mw.title.equals(self.templateTitle, self.title) or self.title:isSubpageOf(self.templateTitle) ) then talk = '#' elseif talk == '' then talk = nil end if talk then -- If the talk value is a talk page, make a link to that page. Else -- assume that it's a section heading, and make a link to the talk -- page of the current page with that section heading. local talkTitle = getTitleObject(talk) local talkArgIsTalkPage = true if not talkTitle or not talkTitle.isTalkPage then talkArgIsTalkPage = false talkTitle = getTitleObject( self.title.text, mw.site.namespaces[self.title.namespace].talk.id ) end if talkTitle and talkTitle.exists then local talkText = '関連議論は' if talkArgIsTalkPage then talkText = string.format( '%s[[%s|%s]]に存在するかもしれません。', talkText, talk, talkTitle.prefixedText ) else talkText = string.format( '%s[[%s#%s|ノートページ]]に存在するかもしれません。', talkText, talkTitle.prefixedText, talk ) end self.talk = talkText end end -- Get other values. self.fix = args.fix ~= '' and args.fix or nil local date if args.date and args.date ~= '' then date = args.date elseif args.date == '' and self.isTemplatePage then date = lang:formatDate('Y年F') end if date then self.date = string.format(" <small>(%s)</small>", date) end self.info = args.info end -- Set the non-collapsible text field. At the moment this is used by all box -- types other than ambox, and also by ambox when small=yes. if self.isSmall then self.text = args.smalltext or args.text else self.text = args.text end -- Set the below row. self.below = cfg.below and args.below -- General image settings. self.imageCellDiv = not self.isSmall and cfg.imageCellDiv self.imageEmptyCell = cfg.imageEmptyCell if cfg.imageEmptyCellStyle then self.imageEmptyCellStyle = 'border:none;padding:0px;width:1px' end -- Left image settings. local imageLeft = self.isSmall and args.smallimage or args.image if cfg.imageCheckBlank and imageLeft ~= 'blank' and imageLeft ~= 'none' or not cfg.imageCheckBlank and imageLeft ~= 'none' then self.imageLeft = imageLeft if not imageLeft then local imageSize = self.isSmall and (cfg.imageSmallSize or '30x30px') or '40x40px' self.imageLeft = string.format('[[File:%s|%s|link=|alt=]]', self.typeImage or 'Imbox notice.png', imageSize) end end -- Right image settings. local imageRight = self.isSmall and args.smallimageright or args.imageright if not (cfg.imageRightNone and imageRight == 'none') then self.imageRight = imageRight end end function MessageBox:setMainspaceCategories() local args = self.args local cfg = self.cfg if not cfg.allowMainspaceCategories then return nil end local nums = {} for _, prefix in ipairs{'cat', 'category', 'all'} do args[prefix .. '1'] = args[prefix] nums = union(nums, getArgNums(args, prefix)) end -- The following is roughly equivalent to the old {{Ambox/category}}. local date = args.date date = type(date) == 'string' and date local preposition = '/' for _, num in ipairs(nums) do local mainCat = args['cat' .. tostring(num)] or args['category' .. tostring(num)] local allCat = args['all' .. tostring(num)] mainCat = type(mainCat) == 'string' and mainCat allCat = type(allCat) == 'string' and allCat if mainCat and date and date ~= '' then local catTitle = string.format('%s%s%s', mainCat, preposition, date) self:addCat(0, catTitle) catTitle = getTitleObject('Category:' .. catTitle) if not catTitle or not catTitle.exists then self:addCat(0, '貼り付け日が正しくないテンプレートのある記事') end elseif mainCat and (not date or date == '') then self:addCat(0, mainCat) end if allCat then self:addCat(0, allCat) end end end function MessageBox:setTemplateCategories() local args = self.args local cfg = self.cfg -- Add template categories. if cfg.templateCategory then if cfg.templateCategoryRequireName then if self.isTemplatePage then self:addCat(10, cfg.templateCategory) end elseif not self.title.isSubpage then self:addCat(10, cfg.templateCategory) end end -- Add template error categories. if cfg.templateErrorCategory then local templateErrorCategory = cfg.templateErrorCategory local templateCat, templateSort if not self.name and not self.title.isSubpage then templateCat = templateErrorCategory elseif self.isTemplatePage then local paramsToCheck = cfg.templateErrorParamsToCheck or {} local count = 0 for i, param in ipairs(paramsToCheck) do if not args[param] then count = count + 1 end end if count > 0 then templateCat = templateErrorCategory templateSort = tostring(count) end if self.categoryNums and #self.categoryNums > 0 then templateCat = templateErrorCategory templateSort = 'C' end end self:addCat(10, templateCat, templateSort) end end function MessageBox:setAllNamespaceCategories() -- Set categories for all namespaces. if self.invalidTypeError then local allSort = (self.title.namespace == 0 and 'Main:' or '') .. self.title.prefixedText self:addCat('all', 'パラメータの修正が必要なメッセージボックス', allSort) end if self.isSubstituted then self:addCat('all', '正しく置き換えられていないテンプレートがあるページ') end end function MessageBox:setCategories() if self.title.namespace == 0 then self:setMainspaceCategories() elseif self.title.namespace == 10 then self:setTemplateCategories() end self:setAllNamespaceCategories() end function MessageBox:renderCategories() -- Convert category tables to strings and pass them through -- [[Module:Category handler]]. return categoryHandler{ main = table.concat(self.categories[0] or {}), template = table.concat(self.categories[10] or {}), all = table.concat(self.categories.all or {}), nocat = self.args.nocat, page = self.args.page } end function MessageBox:export() local root = mw.html.create() -- Add the subst check error. if self.isSubstituted and self.name then root:tag('b') :addClass('error') :wikitext(string.format( 'テンプレート<code>%s[[Template:%s|%s]]%s</code>が正しく置き換えられませんでした。', mw.text.nowiki('{{'), self.name, self.name, mw.text.nowiki('}}') )) end -- Create the box table. local boxTable = root:tag('table') boxTable:attr('id', self.id or nil) for i, class in ipairs(self.classes or {}) do boxTable:addClass(class or nil) end boxTable :cssText(self.style or nil) :attr('role', 'presentation') if self.attrs then boxTable:attr(self.attrs) end -- Add the left-hand image. local row = boxTable:tag('tr') if self.imageLeft then local imageLeftCell = row:tag('td'):addClass('mbox-image') if self.imageCellDiv then -- If we are using a div, redefine imageLeftCell so that the image -- is inside it. Divs use style="width: 52px;", which limits the -- image width to 52px. If any images in a div are wider than that, -- they may overlap with the text or cause other display problems. imageLeftCell = imageLeftCell:tag('div'):css('width', '52px') end imageLeftCell:wikitext(self.imageLeft or nil) elseif self.imageEmptyCell then -- Some message boxes define an empty cell if no image is specified, and -- some don't. The old template code in templates where empty cells are -- specified gives the following hint: "No image. Cell with some width -- or padding necessary for text cell to have 100% width." row:tag('td') :addClass('mbox-empty-cell') :cssText(self.imageEmptyCellStyle or nil) end -- Add the text. local textCell = row:tag('td'):addClass('mbox-text') if self.useCollapsibleTextFields then -- The message box uses advanced text parameters that allow things to be -- collapsible. At the moment, only ambox uses this. textCell:cssText(self.textstyle or nil) local textCellSpan = textCell:tag('span') textCellSpan :addClass('mbox-text-span') :wikitext(self.issue or nil) if not self.isSmall then textCellSpan:tag('span') :addClass('hide-when-compact') :wikitext(self.talk and (' ' .. self.talk) or nil) :wikitext(self.fix and (' ' .. self.fix) or nil) end textCellSpan:wikitext(self.date and (' ' .. self.date) or nil) if not self.isSmall then textCellSpan :tag('span') :addClass('hide-when-compact') :wikitext(self.info and (' ' .. self.info) or nil) end else -- Default text formatting - anything goes. textCell :cssText(self.textstyle or nil) :wikitext(self.text or nil) end -- Add the right-hand image. if self.imageRight then local imageRightCell = row:tag('td'):addClass('mbox-imageright') if self.imageCellDiv then -- If we are using a div, redefine imageRightCell so that the image -- is inside it. imageRightCell = imageRightCell:tag('div'):css('width', '52px') end imageRightCell :wikitext(self.imageRight or nil) end -- Add the below row. if self.below then boxTable:tag('tr') :tag('td') :attr('colspan', self.imageRight and '3' or '2') :addClass('mbox-text') :cssText(self.textstyle or nil) :wikitext(self.below or nil) end -- Add error message for invalid type parameters. if self.invalidTypeError then root:tag('div') :css('text-align', 'center') :wikitext(string.format( 'このメッセージボックスには無効な"type=%s"というパラメータが指定されているため修正が必要です。', self.type or '' )) end -- Add categories. root:wikitext(self:renderCategories() or nil) return tostring(root) end -------------------------------------------------------------------------------- -- Exports -------------------------------------------------------------------------------- local p, mt = {}, {} function p._exportClasses() -- For testing. return { MessageBox = MessageBox } end function p.main(boxType, args, cfgTables) local box = MessageBox.new(boxType, args, cfgTables or mw.loadData('Module:Message box/configuration')) box:setParameters() box:setCategories() return box:export() end function mt.__index(t, k) return function (frame) if not getArgs then getArgs = require('Module:Arguments').getArgs end return t.main(k, getArgs(frame, {trim = false, removeBlanks = false})) end end return setmetatable(p, mt) 3dd60a769a5d1315faa4661358115f17ffa99687 モジュール:Message box/configuration 828 39 81 2016-09-04T14:14:16Z srw>Ochaochaocha3 0 1版 をインポートしました Scribunto text/plain -------------------------------------------------------------------------------- -- Message box configuration -- -- -- -- This module contains configuration data for [[Module:Message box]]. -- -------------------------------------------------------------------------------- return { ambox = { types = { speedy = { class = 'ambox-speedy', image = 'Ambox warning pn.svg' }, delete = { class = 'ambox-delete', image = 'Ambox warning pn.svg' }, content = { class = 'ambox-content', image = 'Ambox important.svg' }, style = { class = 'ambox-style', image = 'Edit-clear.svg' }, move = { class = 'ambox-move', image = 'Merge-split-transwiki default.svg' }, protection = { class = 'ambox-protection', image = 'Padlock-silver-medium.svg' }, notice = { class = 'ambox-notice', image = 'Information icon4.svg' } }, default = 'notice', allowBlankParams = {'talk', 'sect', 'date', 'issue', 'fix', 'subst', 'hidden'}, allowSmall = true, smallParam = 'left', smallClass = 'mbox-small-left', substCheck = true, classes = {--[['metadata',]] 'plainlinks', 'ambox'}, imageEmptyCell = true, imageCheckBlank = true, imageSmallSize = '20x20px', imageCellDiv = true, useCollapsibleTextFields = true, imageRightNone = true, sectionDefault = '記事', allowMainspaceCategories = true, templateCategory = '記事メッセージボックス', templateCategoryRequireName = true, templateErrorCategory = 'パラメータ指定の無い記事メッセージボックス', templateErrorParamsToCheck = {'issue', 'fix', 'subst'} }, cmbox = { types = { speedy = { class = 'cmbox-speedy', image = 'Ambox warning pn.svg' }, delete = { class = 'cmbox-delete', image = 'Ambox warning pn.svg' }, content = { class = 'cmbox-content', image = 'Ambox important.svg' }, style = { class = 'cmbox-style', image = 'Edit-clear.svg' }, move = { class = 'cmbox-move', image = 'Merge-split-transwiki default.svg' }, protection = { class = 'cmbox-protection', image = 'Padlock-silver-medium.svg' }, notice = { class = 'cmbox-notice', image = 'Information icon4.svg' } }, default = 'notice', showInvalidTypeError = true, classes = {'plainlinks', 'cmbox'}, imageEmptyCell = true }, fmbox = { types = { warning = { class = 'fmbox-warning', image = 'Ambox warning pn.svg' }, editnotice = { class = 'fmbox-editnotice', image = 'Information icon4.svg' }, system = { class = 'fmbox-system', image = 'Information icon4.svg' } }, default = 'system', showInvalidTypeError = true, classes = {'plainlinks', 'fmbox'}, imageEmptyCell = false, imageRightNone = false }, imbox = { types = { speedy = { class = 'imbox-speedy', image = 'Ambox warning pn.svg' }, delete = { class = 'imbox-delete', image = 'Ambox warning pn.svg' }, content = { class = 'imbox-content', image = 'Ambox important.svg' }, style = { class = 'imbox-style', image = 'Edit-clear.svg' }, move = { class = 'imbox-move', image = 'Merge-split-transwiki default.svg' }, protection = { class = 'imbox-protection', image = 'Padlock-silver-medium.svg' }, license = { class = 'imbox-license licensetpl', image = 'Imbox license.png' -- @todo We need an SVG version of this }, featured = { class = 'imbox-featured', image = 'Cscr-featured.svg' }, notice = { class = 'imbox-notice', image = 'Information icon4.svg' } }, default = 'notice', showInvalidTypeError = true, classes = {'imbox'}, usePlainlinksParam = true, imageEmptyCell = true, below = true, templateCategory = 'ファイルメッセージボックス' }, ombox = { types = { speedy = { class = 'ombox-speedy', image = 'Ambox warning pn.svg' }, delete = { class = 'ombox-delete', image = 'Ambox warning pn.svg' }, content = { class = 'ombox-content', image = 'Ambox important.svg' }, style = { class = 'ombox-style', image = 'Edit-clear.svg' }, move = { class = 'ombox-move', image = 'Merge-split-transwiki default.svg' }, protection = { class = 'ombox-protection', image = 'Padlock-silver-medium.svg' }, notice = { class = 'ombox-notice', image = 'Information icon4.svg' } }, default = 'notice', showInvalidTypeError = true, classes = {'plainlinks', 'ombox'}, allowSmall = true, imageEmptyCell = true, imageRightNone = true }, tmbox = { types = { speedy = { class = 'tmbox-speedy', image = 'Ambox warning pn.svg' }, delete = { class = 'tmbox-delete', image = 'Ambox warning pn.svg' }, content = { class = 'tmbox-content', image = 'Ambox important.svg' }, style = { class = 'tmbox-style', image = 'Edit-clear.svg' }, move = { class = 'tmbox-move', image = 'Merge-split-transwiki default.svg' }, protection = { class = 'tmbox-protection', image = 'Padlock-silver-medium.svg' }, notice = { class = 'tmbox-notice', image = 'Information icon4.svg' } }, default = 'notice', showInvalidTypeError = true, classes = {'plainlinks', 'tmbox'}, allowSmall = true, imageRightNone = true, imageEmptyCell = true, imageEmptyCellStyle = true, templateCategory = 'ノートページメッセージボックス' } } b6b39dad7bd221ad9a2122ccd6ba7f188ccf3bd4 モジュール:Namespace detect/config 828 40 83 2016-09-04T14:14:16Z srw>Ochaochaocha3 0 1版 をインポートしました Scribunto text/plain -------------------------------------------------------------------------------- -- Namespace detect configuration data -- -- -- -- This module stores configuration data for Module:Namespace detect. Here -- -- you can localise the module to your wiki's language. -- -- -- -- To activate a configuration item, you need to uncomment it. This means -- -- that you need to remove the text "-- " at the start of the line. -- -------------------------------------------------------------------------------- local cfg = {} -- Don't edit this line. -------------------------------------------------------------------------------- -- Parameter names -- -- These configuration items specify custom parameter names. Values added -- -- here will work in addition to the default English parameter names. -- -- To add one extra name, you can use this format: -- -- -- -- cfg.foo = 'parameter name' -- -- -- -- To add multiple names, you can use this format: -- -- -- -- cfg.foo = {'parameter name 1', 'parameter name 2', 'parameter name 3'} -- -------------------------------------------------------------------------------- ---- This parameter displays content for the main namespace: -- cfg.main = 'main' ---- This parameter displays in talk namespaces: -- cfg.talk = 'talk' ---- This parameter displays content for "other" namespaces (namespaces for which ---- parameters have not been specified): -- cfg.other = 'other' ---- This parameter makes talk pages behave as though they are the corresponding ---- subject namespace. Note that this parameter is used with [[Module:Yesno]]. ---- Edit that module to change the default values of "yes", "no", etc. -- cfg.subjectns = 'subjectns' ---- This parameter sets a demonstration namespace: -- cfg.demospace = 'demospace' ---- This parameter sets a specific page to compare: cfg.demopage = 'page' -------------------------------------------------------------------------------- -- Table configuration -- -- These configuration items allow customisation of the "table" function, -- -- used to generate a table of possible parameters in the module -- -- documentation. -- -------------------------------------------------------------------------------- ---- The header for the namespace column in the wikitable containing the list of ---- possible subject-space parameters. -- cfg.wikitableNamespaceHeader = 'Namespace' ---- The header for the wikitable containing the list of possible subject-space ---- parameters. -- cfg.wikitableAliasesHeader = 'Aliases' -------------------------------------------------------------------------------- -- End of configuration data -- -------------------------------------------------------------------------------- return cfg -- Don't edit this line. 0e4ff08d13c4b664d66b32c232deb129b77c1a56 モジュール:Namespace detect/data 828 41 85 2016-09-04T14:14:17Z srw>Ochaochaocha3 0 1版 をインポートしました Scribunto text/plain -------------------------------------------------------------------------------- -- Namespace detect data -- -- This module holds data for [[Module:Namespace detect]] to be loaded per -- -- page, rather than per #invoke, for performance reasons. -- -------------------------------------------------------------------------------- local cfg = require('Module:Namespace detect/config') local function addKey(t, key, defaultKey) if key ~= defaultKey then t[#t + 1] = key end end -- Get a table of parameters to query for each default parameter name. -- This allows wikis to customise parameter names in the cfg table while -- ensuring that default parameter names will always work. The cfg table -- values can be added as a string, or as an array of strings. local defaultKeys = { 'main', 'talk', 'other', 'subjectns', 'demospace', 'demopage' } local argKeys = {} for i, defaultKey in ipairs(defaultKeys) do argKeys[defaultKey] = {defaultKey} end for defaultKey, t in pairs(argKeys) do local cfgValue = cfg[defaultKey] local cfgValueType = type(cfgValue) if cfgValueType == 'string' then addKey(t, cfgValue, defaultKey) elseif cfgValueType == 'table' then for i, key in ipairs(cfgValue) do addKey(t, key, defaultKey) end end cfg[defaultKey] = nil -- Free the cfg value as we don't need it any more. end local function getParamMappings() --[[ -- Returns a table of how parameter names map to namespace names. The keys -- are the actual namespace names, in lower case, and the values are the -- possible parameter names for that namespace, also in lower case. The -- table entries are structured like this: -- { -- [''] = {'main'}, -- ['wikipedia'] = {'wikipedia', 'project', 'wp'}, -- ... -- } --]] local mappings = {} local mainNsName = mw.site.subjectNamespaces[0].name mainNsName = mw.ustring.lower(mainNsName) mappings[mainNsName] = mw.clone(argKeys.main) mappings['talk'] = mw.clone(argKeys.talk) for nsid, ns in pairs(mw.site.subjectNamespaces) do if nsid ~= 0 then -- Exclude main namespace. local nsname = mw.ustring.lower(ns.name) local canonicalName = mw.ustring.lower(ns.canonicalName) mappings[nsname] = {nsname} if canonicalName ~= nsname then table.insert(mappings[nsname], canonicalName) end for _, alias in ipairs(ns.aliases) do table.insert(mappings[nsname], mw.ustring.lower(alias)) end end end return mappings end return { argKeys = argKeys, cfg = cfg, mappings = getParamMappings() } d224f42a258bc308ef3ad8cc8686cd7a4f47d005 モジュール:No globals 828 42 87 2016-09-04T14:14:18Z srw>Ochaochaocha3 0 1版 をインポートしました Scribunto text/plain local mt = getmetatable(_G) or {} function mt.__index (t, k) if k ~= 'arg' then error('Tried to read nil global ' .. tostring(k), 2) end return nil end function mt.__newindex(t, k, v) if k ~= 'arg' then error('Tried to write global ' .. tostring(k), 2) end rawset(t, k, v) end setmetatable(_G, mt) 8ce3969f7d53b08bd00dabe4cc9780bc6afd412a モジュール:Yesno 828 43 89 2016-09-04T14:14:19Z srw>Ochaochaocha3 0 1版 をインポートしました Scribunto text/plain -- Function allowing for consistent treatment of boolean-like wikitext input. -- It works similarly to the template {{yesno}}. return function (val, default) -- If your wiki uses non-ascii characters for any of "yes", "no", etc., you -- should replace "val:lower()" with "mw.ustring.lower(val)" in the -- following line. val = type(val) == 'string' and val:lower() or val if val == nil then return nil elseif val == true or val == 'yes' or val == 'y' or val == 'true' or val == 't' or tonumber(val) == 1 then return true elseif val == false or val == 'no' or val == 'n' or val == 'false' or val == 'f' or tonumber(val) == 0 then return false else return default end end 12981c9a31eb2b0af1be4f16fc0642e180eac8c2 テンプレート:Infobox 10 25 53 2016-09-04T14:26:37Z srw>Ochaochaocha3 0 wikitext text/x-wiki {{#invoke:Infobox/former|main}}<noinclude>{{Documentation}}</noinclude> b659e81634b4e58d9f585cba78a1628dca1ecf2f テンプレート:Documentation 10 24 51 2016-09-04T14:27:25Z srw>Ochaochaocha3 0 wikitext text/x-wiki {{#invoke:Documentation|main|_content={{ {{#invoke:Documentation|contentTitle}}}}}}<noinclude> <!-- Add categories and interwikis to the /doc subpage, not here! --> </noinclude> 9393ef9c27de27bd17c258c2f85cd0f32f196e54 テンプレート:Ombox 10 26 55 2016-09-04T14:34:36Z srw>Ochaochaocha3 0 wikitext text/x-wiki {{#invoke:Message box|ombox}}<noinclude> {{Documentation}} <!-- Add categories and interwikis to the /doc subpage, not here! --> </noinclude> c29c4228977e10054168af738403c6843d92f9a4 モジュール:InfoboxImage 828 37 77 2016-09-04T16:57:55Z srw>Ochaochaocha3 0 1版 をインポートしました Scribunto text/plain -- Inputs: -- image - Can either be a bare filename (with or without the File:/Image: prefix) or a fully formatted image link -- page - page to display for multipage images (DjVu) -- size - size to display the image -- maxsize - maximum size for image -- sizedefault - default size to display the image if size param is blank -- alt - alt text for image -- title - title text for image -- border - set to yes if border -- center - set to yes, if the image has to be centered -- upright - upright image param -- suppressplaceholder - if yes then checks to see if image is a placeholder and suppresses it -- link - page to visit when clicking on image -- Outputs: -- Formatted image. -- More details available at the "Module:InfoboxImage/doc" page local i = {}; local placeholder_image = { "Blue - Replace this image female.svg", "Blue - Replace this image male.svg", "Female no free image yet.png", "Flag of None (square).svg", "Flag of None.svg", "Flag of.svg", "Green - Replace this image female.svg", "Green - Replace this image male.svg", "Image is needed female.svg", "Image is needed male.svg", "Location map of None.svg", "Male no free image yet.png", "Missing flag.png", "No flag.svg", "No free portrait.svg", "No portrait (female).svg", "No portrait (male).svg", "Red - Replace this image female.svg", "Red - Replace this image male.svg", "Replace this image female (blue).svg", "Replace this image female.svg", "Replace this image male (blue).svg", "Replace this image male.svg", "Silver - Replace this image female.svg", "Silver - Replace this image male.svg", "Replace this image.svg", "Cricket no pic.png", "CarersLogo.gif", "Diagram Needed.svg", "Example.jpg", "Image placeholder.png", "No male portrait.svg", "Nocover-upload.png", "NoDVDcover copy.png", "Noribbon.svg", "No portrait-BFD-test.svg", "Placeholder barnstar ribbon.png", "Project Trains no image.png", "Image-request.png", "Sin bandera.svg", "Sin escudo.svg", "Replace this image - temple.png", "Replace this image butterfly.png", "Replace this image.svg", "Replace this image1.svg", "Resolution angle.png", "Image-No portrait-text-BFD-test.svg", "Insert image here.svg", "No image available.png", "NO IMAGE YET square.png", "NO IMAGE YET.png", "No Photo Available.svg", "No Screenshot.svg", "No-image-available.jpg", "Null.png", "PictureNeeded.gif", "Place holder.jpg", "Unbenannt.JPG", "UploadACopyrightFreeImage.svg", "UploadAnImage.gif", "UploadAnImage.svg", "UploadAnImageShort.svg", "CarersLogo.gif", "Diagram Needed.svg", "No male portrait.svg", "NoDVDcover copy.png", "Placeholder barnstar ribbon.png", "Project Trains no image.png", "Image-request.png", } function i.IsPlaceholder(image) -- change underscores to spaces image = mw.ustring.gsub(image, "_", " "); assert(image ~= nil, 'mw.ustring.gsub(image, "_", " ") must not return nil') -- if image starts with [[ then remove that and anything after | if mw.ustring.sub(image,1,2) == "[[" then image = mw.ustring.sub(image,3); image = mw.ustring.gsub(image, "([^|]*)|.*", "%1"); assert(image ~= nil, 'mw.ustring.gsub(image, "([^|]*)|.*", "%1") must not return nil') end -- Trim spaces image = mw.ustring.gsub(image, '^[ ]*(.-)[ ]*$', '%1'); assert(image ~= nil, "mw.ustring.gsub(image, '^[ ]*(.-)[ ]*$', '%1') must not return nil") -- remove prefix if exists local allNames = mw.site.namespaces[6].aliases allNames[#allNames + 1] = mw.site.namespaces[6].name allNames[#allNames + 1] = mw.site.namespaces[6].canonicalName for i, name in ipairs(allNames) do if mw.ustring.lower(mw.ustring.sub(image, 1, mw.ustring.len(name) + 1)) == mw.ustring.lower(name .. ":") then image = mw.ustring.sub(image, mw.ustring.len(name) + 2); break end end -- Trim spaces image = mw.ustring.gsub(image, '^[ ]*(.-)[ ]*$', '%1'); -- capitalise first letter image = mw.ustring.upper(mw.ustring.sub(image,1,1)) .. mw.ustring.sub(image,2); for i,j in pairs(placeholder_image) do if image == j then return true end end return false end function i.InfoboxImage(frame) local image = frame.args["image"]; if image == "" or image == nil then return ""; end if image == "&nbsp;" then return image; end if frame.args["suppressplaceholder"] ~= "no" then if i.IsPlaceholder(image) == true then return ""; end end if mw.ustring.lower(mw.ustring.sub(image,1,5)) == "http:" then return ""; end if mw.ustring.lower(mw.ustring.sub(image,1,6)) == "[http:" then return ""; end if mw.ustring.lower(mw.ustring.sub(image,1,7)) == "[[http:" then return ""; end if mw.ustring.lower(mw.ustring.sub(image,1,6)) == "https:" then return ""; end if mw.ustring.lower(mw.ustring.sub(image,1,7)) == "[https:" then return ""; end if mw.ustring.lower(mw.ustring.sub(image,1,8)) == "[[https:" then return ""; end if mw.ustring.sub(image,1,2) == "[[" then -- search for thumbnail images and add to tracking cat if found if mw.title.getCurrentTitle().namespace == 0 and (mw.ustring.find(image, "|%s*thumb%s*[|%]]") or mw.ustring.find(image, "|%s*thumbnail%s*[|%]]")) then return image .. "[[Category:Infobox内でサムネイル画像を使用しているページ]]"; else return image; end elseif mw.ustring.sub(image,1,2) == "{{" and mw.ustring.sub(image,1,3) ~= "{{{" then return image; elseif mw.ustring.sub(image,1,1) == "<" then return image; elseif mw.ustring.sub(image,1,5) == mw.ustring.char(127).."UNIQ" then -- Found strip marker at begining, so pass don't process at all return image; elseif mw.ustring.sub(image,4,9) == "`UNIQ-" then -- Found strip marker at begining, so pass don't process at all return image; else local result = ""; local page = frame.args["page"]; local size = frame.args["size"]; local maxsize = frame.args["maxsize"]; local sizedefault = frame.args["sizedefault"]; local alt = frame.args["alt"]; local link = frame.args["link"]; local title = frame.args["title"]; local border = frame.args["border"]; local upright = frame.args["upright"] or ""; local thumbtime = frame.args["thumbtime"] or ""; local center= frame.args["center"]; -- remove prefix if exists local allNames = mw.site.namespaces[6].aliases allNames[#allNames + 1] = mw.site.namespaces[6].name allNames[#allNames + 1] = mw.site.namespaces[6].canonicalName for i, name in ipairs(allNames) do if mw.ustring.lower(mw.ustring.sub(image, 1, mw.ustring.len(name) + 1)) == mw.ustring.lower(name .. ":") then image = mw.ustring.sub(image, mw.ustring.len(name) + 2); break end end if maxsize ~= "" and maxsize ~= nil then -- if no sizedefault then set to maxsize if sizedefault == "" or sizedefault == nil then sizedefault = maxsize end -- check to see if size bigger than maxsize if size ~= "" and size ~= nil then local sizenumber = tonumber(mw.ustring.match(size,"%d*")) or 0; local maxsizenumber = tonumber(mw.ustring.match(maxsize,"%d*")) or 0; if sizenumber>maxsizenumber and maxsizenumber>0 then size = maxsize; end end end -- add px to size if just a number if (tonumber(size) or 0) > 0 then size = size .. "px"; end result = "[[File:" .. image; if page ~= "" and page ~= nil then result = result .. "|page=" .. page; end if size ~= "" and size ~= nil then result = result .. "|" .. size; elseif sizedefault ~= "" and sizedefault ~= nil then result = result .. "|" .. sizedefault; else result = result .. "|frameless"; end if center == "yes" then result = result .. "|center" end if alt ~= "" and alt ~= nil then result = result .. "|alt=" .. alt; end if link ~= "" and link ~= nil then result = result .. "|link=" .. link; end if border == "yes" then result = result .. "|border"; end if upright == "yes" then result = result .. "|upright"; elseif upright ~= "" then result = result .. "|upright=" .. upright; end if thumbtime ~= "" then result = result .. "|thumbtime=" .. thumbtime; end if title ~= "" and title ~= nil then result = result .. "|" .. title; elseif alt ~= "" and alt ~= nil then result = result .. "|" .. alt; end result = result .. "]]"; return result; end end return i; 911bef64bf4e15e1a4bba43a593741e72f7762bc テンプレート:Documentation subpage/doc 10 46 93 2016-09-05T05:35:33Z srw>Ochaochaocha3 0 wikitext text/x-wiki <noinclude>{{Documentation subpage}}</noinclude> このテンプレートは、(主にテンプレートの)[[Help:テンプレートの説明文|解説]][[Help:サブページ|サブページ]]であることを告知するために使います。 __TOC__ == 使い方 == === 基本 === 次のコードをページの冒頭に張るだけです: &lt;noinclude&gt;<nowiki>{{Documentation subpage}}</nowiki>&lt;/noinclude&gt; === 解説の対象を指定する === 次のように解説の対象を指定することもできます: &lt;noinclude&gt;<nowiki>{{Documentation subpage|[[Template:X]]}}</nowiki>&lt;/noinclude&gt; === 種類を指定する === 次のように解説の対象の種類を指定することもできます: &lt;noinclude&gt;<nowiki>{{Documentation subpage|種類=[[Help:テンプレート|テンプレート]]}}</nowiki>&lt;/noinclude&gt; == 引数 == {| class="wikitable" border="1" |+ 引数の一覧 ! 引数 !! 指定内容 !! 既定値 !! 説明 |- ! style="text-align:left;" | 1 | ページ名 || <nowiki>[[{{SUBJECTSPACE}}:{{BASEPAGENAME}}]]</nowiki> || 解説の対象を指定。 |- ! style="text-align:left;" | override | サブページ名 || doc || そのテンプレートは、この引数で指定されたサブページ名を持つページでだけ機能します。 |- ! style="text-align:left;" | doc-notice | 任意の文字列 || show || 「show」以外を指定すると、このテンプレートは告知を出力しません。 |- ! style="text-align:left;" | 種類 | 任意の文字列 || {{Tl|SUBJECTSPACE}}ページ<small>(標準名前空間以外のとき)</small><br />記事<small>(標準名前空間のとき)</small>|| 解説の対象の種類を指定。 |} == カテゴリ == このテンプレートは、貼り付けられたページに次のカテゴリを適用します: {| class="wikitable" border="1" |+ 適用するカテゴリの一覧 ! カテゴリ !! ソートキー !! 解説 |- ! style="text-align:left;" | [[:Category:テンプレート文書]] | <nowiki>{{PAGENAME}}</nowiki> | {{ns:10}} 名前空間にあるページのみをカテゴライズします。 |} == 関連項目 == * [[Help:テンプレートの説明文]] * {{Tl|Documentation}} * {{Tl|Template sandbox notice}} * {{Tl|Template test cases notice}} <includeonly> {{デフォルトソート:{{PAGENAME}}}} [[Category:テンプレート文書| ]] [[Category:テンプレート用テンプレート]] </includeonly> b604d646d8fc7c57468109d0fc6b4ba923a451b1 モジュール:Infobox/former 828 36 75 2016-09-05T07:59:34Z srw>Ochaochaocha3 0 args.rowclass Scribunto text/plain local p = {} function p.main(frame) local args = require('Module:Arguments').getArgs(frame, {parentOnly = true}) --引数取得 local child = (args.child == 'yes') local subbox = (args.subbox == 'yes') local h = {subheader = {}, image = {{}}} --ヘッダー部(subheader, image)テーブル local body, sbody = {}, {} --本体部テーブル, ソート済み本体部テーブル local link = args.tnavbar or args.name --(フッター部)テンプレート名 local result = '' --結果格納用 --[[ subheader, image用引数振り分け ]] local function args2tbl(str, k, v) local num = string.match(k, '%d*$') num = (num == '') and 1 or tonumber(num) h[str][num] = h[str][num] or {} if k == str then h[str][1][1] = v elseif string.match(k, str .. '%d+') then h[str][num][1] = v elseif string.find(k, 'style') then if string.match(k, 'style$') then h[str]['style'] = v else h[str][num]['style'] = v end elseif string.find(k, 'rowclass') then if string.match(k, 'rowclass$') then h[str]['rowclass'] = v else h[str][num]['rowclass'] = v end elseif string.match(k, 'class$') then h[str]['class'] = v end end --[[ 引数振り分け ]] for k, v in pairs(args) do --subheader if string.find(k, 'subheader') then args2tbl('subheader', k, v) --image elseif string.find(k, 'image') then args2tbl('image', k, v) elseif string.find(k, 'caption') then if string.match(k, 'caption$') then h['image'][1]['caption'] = '<div style="' .. (args.captionstyle or '') .. '">' .. v .. '</div>' elseif string.match(k, 'caption%d+') then local num = tonumber(string.match(k, '%d*$')) h['image'][num] = h['image'][num] or {} h['image'][num]['caption'] = '<div style="' .. (args.captionstyle or '') .. '">' .. v .. '</div>' end --その他(本体部) elseif string.match(k, '^%D+%d+$') then local str, num = string.match(k, '^(%D+)(%d+)$') num = tonumber(num) if not body[num] then local OddOrEven = (num % 2 ~= 0) and 'odd' or 'even' body[num] = { num, headerstyle = (args.headerstyle or '') .. (args[OddOrEven .. 'headerstyle'] or ''), labelstyle = (args.labelstyle or '') .. (args[OddOrEven .. 'labelstyle'] or ''), datastyle = (args.datastyle or '') .. (args[OddOrEven .. 'datastyle'] or '') } end body[num][str] = (body[num][str] or '') .. v end end --[[ Template:Infobox/row ]] local function row(header, headerstyle, label, labelstyle, data, datastyle, rowstyle, class, rowclass, id, itemprop, rowitemprop, itemtype, rowitemtype, itemref, rowitemref) local result ='' if header then result = '<tr style="' .. (rowstyle or '') ..'"' .. (rowitemtype and (' itemscope itemtype="' .. rowitemtype .. '"') or '') .. ' itemref="' .. (rowitemref or '') .. '"><th scope="col" colspan="2" class="' .. (class or '') .. '" style="text-align:center; ' .. (headerstyle or '') .. '">' .. header .. '</th></tr>' elseif data then result = '<tr class="' .. (rowclass or '') .. '" style="' .. (rowstyle or '') .. '" itemprop="' .. (rowitemprop or '') .. '"' .. (rowitemtype and (' itemscope itemtype="' .. rowitemtype .. '"') or '') .. ' itemref="' .. (rowitemref or '') .. '">' if label then result = result .. '<th scope="row" style="text-align:left; white-space:nowrap; ' .. (labelstyle or '') .. '">' .. label .. '</th><td class="' .. (class or '') .. '" style="' .. (datastyle or '') .. '" itemprop="' .. (itemprop or '') .. '"' .. (itemtype and (' itemscope itemtype="' .. itemtype .. '"') or '') .. ' itemref="' .. (itemref or '') .. '">' else result = result .. '<td colspan="2" class="' .. (class or '') .. '" style="text-align:center; ' .. (datastyle or '') .. '" itemprop="' .. (itemprop or '') .. '"' .. (itemtype and (' itemscope itemtype="' .. rowitemtype .. '"') or '') .. ' itemref="' .. (itemref or '') .. '">' end result = result .. '\n' .. data .. '</td></tr>' end return result end --[[ Template:Infobox ]] --ヘッダー部 if not child then --tableタグ result = '<table class="' .. (subbox and '' or 'infobox ') .. (args.bodyclass or '') .. '" style="' .. (subbox and 'min-width:100%; width:calc(100% + 6px); margin:-3px; ' or 'width:22em; ') .. (args.bodystyle or '') .. '"' .. (args.bodyitemtype and (' itemscope itemtype="' .. args.bodyitemtype .. '"') or '') .. ' itemref="' .. (args.bodyitemref or '') .. '">' if args.title then --captionタグ result = result .. '<caption itemprop="name" class="' .. (args.titleclass or '') .. ' style="' .. (args.titlestyle or '') .. '">' .. args.title .. '</caption>' end if args.above then result = result .. '<tr><th colspan="2" class="' .. (args.aboveclass or '') .. '" style="text-align:center; font-size:125%; font-weight:bold; ' .. (args.abovestyle or '') .. '" itemprop="' .. (args.aboveitemprop or '') .. '"' .. (args.aboveitemtype and (' itemscope itemtype="' .. args.aboveitemtype .. '"') or '') .. ' itemref="' .. (args.aboveitemref or '') .. '">' .. args.above ..'</th></tr>' end else if args.title then result = '<b itemprop="name' .. '"' .. (args.bodyitemtype and (' itemscope itemtype="' .. args.bodyitemtype .. '"') or '') .. ' itemref="' .. (args.bodyitemref or '') .. '">' .. args.title .. '</b>' end end for k, v in pairs(h.subheader) do result = result .. row(nil, nil, nil, nil, v[1], v.style or h.subheader.style, v.rowstyle, h.subheader.class, v.rowclass, nil, nil, nil, nil, nil, nil, nil) end for k, v in pairs(h.image) do result = result .. row(nil, nil, nil, nil, v[1] and (v[1] .. (v.caption or '')), v.style or h.image.style, v.rowstyle, h.image.class, v.rowclass, nil, nil, nil, nil, nil, nil, nil) end --本体部ソート for k, v in pairs(body) do sbody[#sbody + 1] = v end table.sort(sbody, function (a, b) return a[1] < b[1] end ) --本体部 for k, v in ipairs(sbody) do result = result .. row(v.header, v.headerstyle, v.label, v.labelstyle, v.data, v.datastyle, v.rowstyle, v.class, v.rowclass or args.rowclass, v.id, v.itemprop, v.rowitemprop, v.itemtype, v.rowitemtype, v.itemref, v.rowitemref) end --フッター部 if args.below then result = result .. '<tr><td colspan="2" class="' .. (args.belowclass or '') .. '" style="text-align:center; ' .. (args.belowstyle or '') .. '">' .. args.below .. '</td></tr>' end if link then --Template:Transclude link = string.gsub(link, ':?[Tt]emplate:', '') if not string.find(link, ':') then link = 'Template:' .. link end result = result .. '<tr class="noprint"><td colspan=2 style="text-align:right; font-size:85%;">[[' .. link .. '|テンプレートを表示]]</td></tr>' end --tableタグ閉じ if not child then result = result .. '</table>' end --出力 return result end return p 664796a7cacee7fefae945001974b596fb3a82e0 テンプレート:概要テンプレート・編集 10 27 57 2017-03-20T12:17:19Z srw>Ochaochaocha3 0 クエリパラメータを修正する wikitext text/x-wiki <noinclude>{{DEFAULTSORT:かいようてんふれえと へんしゆう}} [[Category:テンプレート]]</noinclude>{{Ombox | type = content | text = このテンプレートを編集する場合は「'''{{#if:{{{1|}}}|[{{fullurl:特別:概要テンプレートエディタ|wptemplate-page-to-load={{{1}}}}} 特別:概要テンプレートエディタ]|[[特別:概要テンプレートエディタ]]}}'''」を使用してください。 }} d7b95d757606321ca88e552c9d31904f1067e695 MediaWiki:Common.css 8 12 19 2019-01-31T14:05:20Z gundam>Ochaochaocha3 0 スパロボWikiからコピー css text/css /* ここに書いた CSS はすべての外装に反映されます */ /* <source lang="css"> */ /* preのはみ出し */ pre { overflow-x: auto; } /* 表:値なし */ .wikitable .none { text-align: center; } /* 表:数値 */ .wikitable .num { text-align: right; } /* 記事名チェック・ネタバレ規制の警告 */ .titleChecker-warn, .netabare-warn { margin: 1em 0; padding: 0 1em; border: 2px solid #f03; background-color: #fcc; } /* 引用 */ blockquote { position: relative; margin: 1em 0; padding: 1em 1em 1em 3em; background-color: #f9f9f9; border: 1px solid #ddd; } blockquote:before { position: absolute; top: 10px; left: 10px; line-height: 1; /* Left double quote */ content: "\201C"; font-family: Georgia, serif; font-size: 60px; color: #455372; } /* メインページのモバイルビュー専用項目 */ .main-page-mobile-view { display: none; } /* wikitable/prettytable class for skinning normal tables */ table.prettytable { background: #f9f9f9; border: 1px solid #aaa; border-collapse: collapse; } table.prettytable th, table.prettytable td { border: 1px solid #aaa; padding: 0.2em; } table.prettytable th { background: #f2f2f2; text-align: center; } table.prettytable caption { margin-left: inherit; margin-right: inherit; } /* default skin for navigation boxes */ /* navbox container style */ table.navbox { box-sizing: border-box; border: 1px solid #aaa; width: 100%; margin: auto; clear: both; font-size: 88%; text-align: center; padding: 1px; } /* single pixel border between adjacent navboxes (doesn't work for IE6, but that's okay) */ table.navbox + table.navbox { margin-top: -1px; } /* title and above/below styles */ .navbox-title, .navbox-abovebelow, table.navbox th { text-align: center; padding-left: 1em; padding-right: 1em; } /* group style */ .navbox-group { white-space: nowrap; text-align: right; font-weight: bold; padding-left: 1em; padding-right: 1em; } /* Level 1 color */ .navbox-title, table.navbox th, .infobox-above { background: #ABD692; } /* Level 2 color */ .navbox-abovebelow, .navbox-group, .navbox-subgroup .navbox-title, .infobox-row th { background: #C3DEAD; } /* Level 3 color */ .navbox-subgroup .navbox-group, .navbox-subgroup .navbox-abovebelow { background: #E3E3E3; } /* Even row striping */ .navbox-even { background: #f7f7f7; } /* Odd row striping */ .navbox-odd { background: transparent; } /* [[MediaWiki:Common.js]] にある createCollapseButtons 関数を参照。 */ .collapseButton { float: right; font-weight: normal; text-align: right; width: auto; } /* [[Template:Navbox]] に配置する場合、左に配置されている [[Template:Tnavbar]] とのバランスを取る。 */ .navbox .collapseButton { width: 6em; } /* [[en:MediaWiki:Common.css]] から複製。 */ /* Style for horizontal lists (separator following item). Note: hlist formatting will break if the resulting HTML lacks a breakable character between list items. This happens when the following conditions are true: 1) The list is made using wiki markup (where HTML is built by parser.php) 2) HTMLTidy is disabled or unavailable (such as on Special: pages) In such cases, building lists with .hlist using HTML instead of wiki markup will work around this problem. See also [[Bugzilla:39617]]. IE8-specific classes are assigned in [[MediaWiki:Common.js/IEFixes.js]]. Last updated: January 24, 2013 @source mediawiki.org/wiki/Snippets/Horizontal_lists @maintainer: [[User:Edokter]] @revision: 3.1 */ .skin-monobook .hlist dl, .skin-modern .hlist dl, .skin-vector .hlist dl { line-height: 1.5em; } .hlist dl, .hlist ol, .hlist ul { margin: 0; padding: 0; } /* Display list items inline and make them nowrap */ .hlist dd, .hlist dt, .hlist li { margin: 0; display: inline; white-space: nowrap; } /* Allow wrapping for list items (in tight spaces) */ .hlist.hwrap dd, .hlist.hwrap dt, .hlist.hwrap li { white-space: normal; } /* Display nested lists inline and allow them to wrap */ .hlist dl dl, .hlist dl ol, .hlist dl ul, .hlist ol dl, .hlist ol ol, .hlist ol ul, .hlist ul dl, .hlist ul ol, .hlist ul ul { display: inline; white-space: normal; } /* Generate interpuncts */ .hlist dt:after { content: ":"; } .hlist dd:after, .hlist li:after { content: " ·"; font-weight: bold; } /* 日本語版の独自仕様。-pipe と -hyphen */ .hlist-pipe dd:after, .hlist-pipe li:after { content: " |"; font-weight: normal; } .hlist-hyphen dd:after, .hlist-hyphen li:after { content: " -"; font-weight: normal; } .hlist dd:last-child:after, .hlist dt:last-child:after, .hlist li:last-child:after { content: none; } /* For IE8 */ .hlist dd.hlist-last-child:after, .hlist dt.hlist-last-child:after, .hlist li.hlist-last-child:after { content: none; } /* Add parentheses around nested lists */ .hlist dd dd:first-child:before, .hlist dd dt:first-child:before, .hlist dd li:first-child:before, .hlist dt dd:first-child:before, .hlist dt dt:first-child:before, .hlist dt li:first-child:before, .hlist li dd:first-child:before, .hlist li dt:first-child:before, .hlist li li:first-child:before { content: "("; font-weight: normal; } .hlist dd dd:last-child:after, .hlist dd dt:last-child:after, .hlist dd li:last-child:after, .hlist dt dd:last-child:after, .hlist dt dt:last-child:after, .hlist dt li:last-child:after, .hlist li dd:last-child:after, .hlist li dt:last-child:after, .hlist li li:last-child:after { content: ")"; font-weight: normal; } /* For IE8 */ .hlist dd dd.hlist-last-child:after, .hlist dd dt.hlist-last-child:after, .hlist dd li.hlist-last-child:after, .hlist dt dd.hlist-last-child:after, .hlist dt dt.hlist-last-child:after, .hlist dt li.hlist-last-child:after, .hlist li dd.hlist-last-child:after, .hlist li dt.hlist-last-child:after, .hlist li li.hlist-last-child:after { content: ")"; font-weight: normal; } /* Put numbers in front of ordered list items */ .hlist.hnum ol { counter-reset: list-item; } .hlist.hnum ol > li { counter-increment: list-item; } .hlist.hnum ol > li:before { content: counter(list-item) ".\a0"; } .hlist.hnum dd ol > li:first-child:before, .hlist.hnum dt ol > li:first-child:before, .hlist.hnum li ol > li:first-child:before { content: "(" counter(list-item) " "; } /* Avoid elements from breaking between columns */ .nocolbreak, li, dd { -webkit-column-break-inside: avoid; page-break-inside: avoid; break-inside: avoid-column; } dt { -webkit-column-break-after: avoid; page-break-after: avoid; break-after: avoid-column; } dd { -webkit-column-break-before: avoid; page-break-before: avoid; break-before: avoid-column; } /* default skin for navigation boxes */ /* navbox container style */ table.navbox { box-sizing: border-box; border: 1px solid #aaa; width: 100%; margin: 1em 0; clear: both; font-size: 88%; text-align: center; padding: 1px; } /* single pixel border between adjacent navboxes (doesn't work for IE6, but that's okay) */ table.navbox + table.navbox { margin-top: -1px; } /* title and above/below styles */ .navbox-title, .navbox-abovebelow, table.navbox th { text-align: center; padding-left: 1em; padding-right: 1em; } /* group style */ .navbox-group { white-space: nowrap; text-align: right; font-weight: bold; padding-left: 1em; padding-right: 1em; } /* Style for "notices" */ .notice { text-align: justify; margin: 1em; padding: 0.2em; } #disambig { border-top: 3px double #ccc; border-bottom: 3px double #ccc; } #spoiler { border-top: 2px solid #ddd; border-bottom: 2px solid #ddd; } /* Standard talk template style */ .Talk-Notice { box-sizing: border-box; border: 1px solid #c0c090; background-color: #f8eaba; margin-bottom: 3px; width: 85%; border-spacing: 3px; margin-left: auto; margin-right: auto; } .Talk-Notice:after { content: "The CSS for this template should be changed. See [[Wikipedia:Template Standardisation]]." } /* Make template background appear correctly on all browsers */ .Talk-Notice td { background: inherit; } /* Metadata */ table.metadata { border: 1px solid #aaa; display: none; } .metadata-label { color: #aaa; } /* Add formatting to make sure that "external references" from [[Template:Ref]] do not get URL expansion, not even when printed. The mechanism up to MediaWiki 1.4 was that the HTML code contained a SPAN following the anchor A; this SPAN had the class "urlexpansion", which was not displayed on screen, but was shown when the medium was "print". The rules below ensure (a) that there is no extra padding to the right of the anchor (displayed as "[<number>]"), (b) that there is no "external link arrow" for the link, and (c) that this SPAN of class "urlexpansion" is never shown. ~~~~ */ .plainlinksneverexpand { background: none !important; padding: 0 !important; } .plainlinksneverexpand .urlexpansion { display: none !important; } /* Make sure that ext links displayed within "plainlinksneverexpand" don't get the arrow... */ .plainlinksneverexpand a { background: none !important; padding: 0 !important } /* With MediaWiki 1.5, the mechanism has changed: instead of a SPAN of class "urlexpansion" following the anchor A, the anchor itself now has class "external autonumber" and the expansion is inserted when printing (see the common printing style sheet at //en.wikipedia.org/skins-1.5/common/commonPrint.css) using the ":after" pseudo- element of CSS. We have to switch this off for links due to Template:Ref! ~~~~ */ .plainlinksneverexpand a.external.text:after { display: none !important; } .plainlinksneverexpand a.external.autonumber:after { display: none !important; } /* Merge template style */ .messagebox { box-sizing: border-box; border: 1px solid #aaa; background: #f9f9f9; width: 80%; margin: 0 auto 1em auto; padding: 0.2em; text-align: justify; } .messagebox.merge { box-sizing: border-box; border: 2px solid #033; width: 55%; background: #eff; padding: 1em; margin: 1em auto 1em auto; } .messagebox.cleanup { border: 1px solid #9f9fff; background: #efefff; text-align: center; } .messagebox.standard-talk { border: 1px solid #c0c090; background: #f8eaba; } .infobox { border: 1px solid #aaa; background-color: #f9f9f9; color: black; margin: 0.5em 0 0.5em 1em; padding: 0.2em; float: right; clear: right; text-align: left; font-size: 88%; line-height: 1.5em; } .infobox caption { margin-top: 0.5em; font-size: 125%; font-weight: bold; } .infobox td, .infobox th { padding: 0.2em; vertical-align: top; } .infobox.bordered { border-collapse: collapse; } .infobox.bordered td, .infobox.bordered th { border: 1px solid #aaa; } .infobox.bordered .borderless td, .infobox.bordered .borderless th { border: 0; } .infobox.sisterproject { width: 20em; font-size: 90%; } .infobox td > p, .infobox td > dl { margin: 0; } .infobox td ul { margin-top: 0; margin-left: 1.25em; } .infobox dd { margin-left: 1em; } #wpSave { font-weight: bold; } /* hiddenStructure from Monobook - allows selective hiding of markup in templates */ .hiddenStructure { display: none; speak: none; } /* Icons for medialist templates [[Template:Listen]], [[Template:Multi-listen_start]], [[Template:Video]], [[Template:Multi-video_start]] */ div.listenlist { background: url("//upload.wikimedia.org/wikipedia/commons/thumb/a/a6/Gnome-speakernotes.png/30px-Gnome-speakernotes.png"); padding-left: 40px; } div.videolist, div.multivideolist { background: url("//upload.wikimedia.org/wikipedia/en/thumb/2/20/Tango-video-x-generic.png/40px-Tango-video-x-generic.png"); padding-left: 50px; } /* Style rules for media list templates */ div.medialist { min-height: 50px; margin: 1em; background-position: top left; background-repeat: no-repeat; } div.medialist ul { list-style-type: none; list-style-image: none; margin: 0; } div.medialist ul li { padding-bottom: 0.5em; } div.medialist ul li li { font-size: 91%; padding-bottom: 0; } /************************/ /* CommonsTicker styles */ /************************/ /* links */ .tickerDiffLink { } /* diff links in ticker */ .tickerMiscLink { } /* misc links in ticker */ /* remove list bullets */ .tickerList ul, .tickerList ul li { list-style: none; text-indent: -2em; margin-left: 2em; text-align: left; } .tickerList ul ul, .tickerList ul ul li { list-style: none; text-indent: 0; margin-left: 1.5em; text-align: left; } /* per-type styles */ .tickerEntry_deleted { } /* entry for image deletion */ .tickerEntry_replaced { } /* entry for image replacement */ .tickerEntry_tagged { } /* entry for adding/removing problem tags */ .tickerEntry_redir { } /* entry for critical redirection (fot tag redirects) */ .tickerEntry_recat { } /* entry for critical re-categorization (for tag categories) */ .tickerEntry_notify { } /* entry for global notifications */ .tickerEntry_changed { } /* entry for generic change */ /* per-action styles */ .tickerAction_deleted:before { content: " GONE "; color: #FF0000; font-family: monospace; font-weight: bold; font-size: 100%; } .tickerAction_deletedRev:before { content: " -OLD "; color: #DDAAAA; font-family: monospace; font-weight: bold; font-size: 100%; } .tickerAction_replaced:before { content: " REPL "; color: #CC88FF; font-family: monospace; font-weight: bold; font-size: 100%; } .tickerAction_replacedOwn:before { content: " UPDT "; color: #EEAAFF; font-family: monospace; font-weight: bold; font-size: 100%; } .tickerAction_addedBad:before { content: " +VfD "; color: #FF8800; font-family: monospace; font-weight: bold; font-size: 100%; } .tickerAction_removedBad:before { content: " -VfD "; color: #00BB00; font-family: monospace; font-weight: bold; font-size: 100%; } .tickerAction_addedGood:before { content: " +OK "; color: #00BB00; font-family: monospace; font-weight: bold; font-size: 100%; } .tickerAction_removedGood:before { content: " -OK "; color: #FF8800; font-family: monospace; font-weight: bold; font-size: 100%; } /* ticker usage list */ .tickerUsage { font-size: 80%; } /* entry applies to a template used by multiple images */ .tickerTemplateEntry { font-weight: bold; } /* entry applies to sub-entries, i.e. images that use a specific template */ .tickerSubEntry { } /* minor entry styles */ /* minor entry */ .tickerMinorEntry { color: #666; } .tickerMinorEntry a, .tickerMinorEntry a:link, .tickerMinorEntry a:visited { color: #669; } #bodyContent .tickerMinorEntry a.extiw, #bodyContent .tickerMinorEntry a.extiw:link, #bodyContent .tickerMinorEntry a.extiw:visited { color: #669; } /* Change the external link icon to an Adobe icon anywhere the PDFlink class */ /* is used (notably Template: PDFlink). This works in IE, unlike the above. */ span.PDFlink a { background: url(//upload.wikimedia.org/wikipedia/commons/2/23/Icons-mini-file_acrobat.gif) center right no-repeat !important; padding-right: 17px !important; } /* ### nowrap for some table headings ### */ label[for="wpUserEmail"], label[for="wpNick"], label[for="wpUserLanguage"], label[for="wpOldpass"], label[for="wpNewpass"], label[for="wpRetypePass"], #userlogin2 label, #userloginForm label { white-space: nowrap } /* リダイレクトの表示 */ /* [[特別:Allpages]]・[[特別:Prefixindex]] */ .allpagesredirect a:link, .allpagesredirect a:visited, /* カテゴリ内 */ .redirect-in-category a:link, .redirect-in-category a:visited, /* ウォッチリスト */ .watchlistredir a:link, .watchlistredir a:visited { color: #666; } /* NavFrame関係。[[MediaWiki:Monobook.css]]も参照 */ div.Boxmerge, div.NavFrame { margin: 0; padding: 2px; border: 1px solid #aaaaaa; text-align: center; border-collapse: collapse; font-size: 95%; } div.Boxmerge div.NavFrame { border-style: none; border-style: hidden; } div.NavPic { background-color: #ffffff; margin: 0px; padding: 2px; float: left; } div.NavFrame div.NavHead { height: 1.6em; font-weight: bold; font-size: 100%; background-color: #efefef; position: relative; text-align: center; } div.NavFrame p { font-size: 100%; } div.NavFrame div.NavContent { font-size: 100%; } div.NavFrame div.NavContent p { font-size: 100%; } div.NavEnd { margin: 0px; padding: 0px; line-height: 1px; clear: both; } a.NavToggle { position: absolute; top: 0px; right: 3px; font-weight: normal; /* font-size: 83.3%;*/ } /* Article message box styles */ table.ambox { margin: 0 10%; /* 10% = 他の要素にはみ出るのを防ぐ */ border: 1px solid #aaa; border-left: 10px solid #1e90ff; /* 初期値: "notice" の青 */ background: #fbfbfb; } table.ambox + table.ambox { /* 重なったボックスの間を単一の罫線に */ margin-top: -1px; } .ambox th.mbox-text, .ambox td.mbox-text { /* メッセージ本体のセル */ padding: 0.25em 0.5em; /* 左右に 0.5em ずつの余白 */ } .ambox td.mbox-image { /* 左の画像セル */ padding: 2px 0 2px 0.5em; /* 左に 0.5em、右に 0px の余白 */ } .ambox td.mbox-imageright { /* 右の画像セル */ padding: 2px 0.5em 2px 0; /* 左に 0px、右に 0.5em の余白 */ } table.ambox-notice { border-left: 10px solid #1e90ff; /* 青 */ } table.ambox-speedy { border-left: 10px solid #b22222; /* 赤 */ background: #fee; /* 桃 */ } table.ambox-delete { border-left: 10px solid #b22222; /* 赤 */ } table.ambox-content { border-left: 10px solid #f28500; /* 橙 */ } table.ambox-style { border-left: 10px solid #f4c430; /* 黄 */ } table.ambox-move { border-left: 10px solid #9932cc; /* 紫 */ } table.ambox-protection { border-left: 10px solid #bba; /* 灰色・金色 */ } /* Cell sizes for ambox/tmbox/imbox/cmbox/ombox/fmbox/dmbox message boxes */ th.mbox-text, td.mbox-text { /* The message body cell(s) */ box-sizing: border-box; border: none; padding: 0.25em 0.9em; /* 0.9em left/right */ width: 100%; /* Make all mboxes the same width regardless of text length */ font-size: 90%; } td.mbox-image { /* The left image cell */ border: none; padding: 2px 0 2px 0.9em; /* 0.9em left, 0px right */ text-align: center; } td.mbox-imageright { /* The right image cell */ border: none; padding: 2px 0.9em 2px 0; /* 0px left, 0.9em right */ text-align: center; } td.mbox-empty-cell { /* An empty narrow cell */ border: none; padding: 0; width: 1px; } /* * [[MediaWiki:Revision-info]]、[[MediaWiki:Revision-info-current]]のフォントサイズ調整。 * 2010-07-15 by [[User:Penn Station]] */ #revision-info, #revision-info-current { font-size: small; margin-top: 4px; } /* ambox - 以下、日本語版の独自拡張 */ table.ambox div.ambox-imagecontainer { /* 画像セル内の画像表示領域 */ width: 52px; } table.ambox.ambox-section { /* 節用メッセージボックス */ margin: 0 10%; } table.ambox.ambox-section div.ambox-imagecontainer { width: 52px; } table.ambox.ambox-section th.mbox-text, table.ambox.ambox-section td.mbox-text { padding: 0.25em 0.5em; } /* Image message box styles */ table.imbox { margin: 4px 10%; border-collapse: collapse; border: 3px solid #1e90ff; /* Default "notice" blue */ background: #fbfbfb; } .imbox .mbox-text .imbox { /* For imboxes inside imbox-text cells. */ margin: 0 -0.5em; /* 0.9 - 0.5 = 0.4em left/right. */ } .mbox-inside .imbox { /* For imboxes inside other templates. */ margin: 4px; } table.imbox-notice { border: 3px solid #1e90ff; /* Blue */ } table.imbox-speedy { border: 3px solid #b22222; /* Red */ background: #fee; /* Pink */ } table.imbox-delete { border: 3px solid #b22222; /* Red */ } table.imbox-content { border: 3px solid #f28500; /* Orange */ } table.imbox-style { border: 3px solid #f4c430; /* Yellow */ } table.imbox-move { border: 3px solid #9932cc; /* Purple */ } table.imbox-protection { border: 3px solid #bba; /* Gray-gold */ } table.imbox-license { border: 3px solid #88a; /* Dark gray */ background: #f7f8ff; /* Light gray */ } table.imbox-featured { border: 3px solid #cba135; /* Brown-gold */ } /* Category message box styles */ table.cmbox { margin: 3px 10%; border-collapse: collapse; border: 1px solid #aaa; background: #DFE8FF; /* Default "notice" blue */ } table.cmbox-notice { background: #DFE8FF; /* Blue */ } table.cmbox-speedy { margin-top: 4px; margin-bottom: 4px; border: 4px solid #b22222; /* Red */ background: #FFDBDB; /* Pink */ } table.cmbox-delete { background: #FFDBDB; /* Red */ } table.cmbox-content { background: #FFE7CE; /* Orange */ } table.cmbox-style { background: #FFF9DB; /* Yellow */ } table.cmbox-move { background: #E4D8FF; /* Purple */ } table.cmbox-protection { background: #EFEFE1; /* Gray-gold */ } /* Other pages message box styles */ table.ombox { margin: 4px 10%; border-collapse: collapse; border: 1px solid #aaa; /* Default "notice" gray */ background: #f9f9f9; } table.ombox-notice { border: 1px solid #aaa; /* Gray */ } table.ombox-speedy { border: 2px solid #b22222; /* Red */ background: #fee; /* Pink */ } table.ombox-delete { border: 2px solid #b22222; /* Red */ } table.ombox-content { border: 1px solid #f28500; /* Orange */ } table.ombox-style { border: 1px solid #f4c430; /* Yellow */ } table.ombox-move { border: 1px solid #9932cc; /* Purple */ } table.ombox-protection { border: 2px solid #bba; /* Gray-gold */ } /* Talk page message box styles */ table.tmbox { margin: 4px 10%; border-collapse: collapse; border: 1px solid #c0c090; /* Default "notice" gray-brown */ background: #f8eaba; } .mediawiki .mbox-inside .tmbox { /* For tmboxes inside other templates. The "mediawiki" */ margin: 2px 0; /* class ensures that this declaration overrides other */ width: 100%; /* For Safari and Opera */ /* styles (including mbox-small above) */ } .mbox-inside .tmbox.mbox-small { /* "small" tmboxes should not be small when */ line-height: 1.5em; /* also "nested", so reset styles that are */ font-size: 100%; /* set in "mbox-small" above. */ } table.tmbox-speedy { border: 2px solid #b22222; /* Red */ background: #fee; /* Pink */ } table.tmbox-delete { border: 2px solid #b22222; /* Red */ } table.tmbox-content { border: 2px solid #f28500; /* Orange */ } table.tmbox-style { border: 2px solid #f4c430; /* Yellow */ } table.tmbox-move { border: 2px solid #9932cc; /* Purple */ } table.tmbox-protection, table.tmbox-notice { border: 1px solid #c0c090; /* Gray-brown */ } /* Disambig and set index box styles */ table.dmbox { clear: both; margin: 0.9em 1em; border-top: 1px solid #ccc; border-bottom: 1px solid #ccc; background: transparent; } /* Footer and header message box styles */ table.fmbox { clear: both; margin: 0.2em 0; width: 100%; border: 1px solid #aaa; background: #f9f9f9; /* Default "system" gray */ } table.fmbox-system { background: #f9f9f9; } table.fmbox-warning { border: 1px solid #bb7070; /* Dark pink */ background: #ffdbdb; /* Pink */ } table.fmbox-editnotice { background: transparent; } /* Div based "warning" style fmbox messages. */ div.mw-warning-with-logexcerpt, div.mw-lag-warn-high, div.mw-cascadeprotectedwarning, div#mw-protect-cascadeon { clear: both; margin: 0.2em 0; border: 1px solid #bb7070; background: #ffdbdb; padding: 0.25em 0.9em; } /* Div based "system" style fmbox messages. Used in [[MediaWiki:Noarticletext]] and [[MediaWiki:Readonly lag]]. */ div.mw-lag-warn-normal, div.noarticletext, div.fmbox-system { clear: both; margin: 0.2em 0; border: 1px solid #aaa; background: #f9f9f9; padding: 0.25em 0.9em; } /* These mbox-small classes must be placed after all other ambox/tmbox/ombox etc classes. "body.mediawiki" is so they override "table.ambox + table.ambox" above. */ body.mediawiki table.mbox-small { /* For the "small=yes" option. */ clear: right; float: right; margin: 4px 0 4px 1em; width: 238px; font-size: 88%; line-height: 1.25em; } body.mediawiki table.mbox-small-left { /* For the "small=left" option. */ margin: 4px 1em 4px 0; width: 238px; border-collapse: collapse; font-size: 88%; line-height: 1.25em; } /* [[Template: Pathnav]] */ .pathnavbox { clear: both; border: 1px outset #eef; padding: 0.3em 0.6em; margin: 0 0 0.5em 0; background-color: #eef; font-size: 90%; } .pathnavbox ul { list-style: none none; margin-top: 0; margin-bottom: 0; } .pathnavbox > ul { margin: 0; } .pathnavbox ul li { margin: 0; } /* 脚注ジャンプ先強調 */ ol.references > li:target { background-color: #DEF; } sup.reference:target { background-color: #DEF; } cite:target { background-color: #DEF; } /* Otheruses等の冒頭曖昧さ回避テンプレート */ .dablink { margin: 0.5em 0; padding: 3px 2em; background-color: transparent; border-bottom: 1px solid #aaa; font-size: 90%; } /* </source> */ 8fb992e8de56ef3c7a21ef9ed1fa2c0097a8e56c 20 19 2019-06-23T13:26:46Z Ochaochaocha3 1 1版 をインポートしました css text/css /* ここに書いた CSS はすべての外装に反映されます */ /* <source lang="css"> */ /* preのはみ出し */ pre { overflow-x: auto; } /* 表:値なし */ .wikitable .none { text-align: center; } /* 表:数値 */ .wikitable .num { text-align: right; } /* 記事名チェック・ネタバレ規制の警告 */ .titleChecker-warn, .netabare-warn { margin: 1em 0; padding: 0 1em; border: 2px solid #f03; background-color: #fcc; } /* 引用 */ blockquote { position: relative; margin: 1em 0; padding: 1em 1em 1em 3em; background-color: #f9f9f9; border: 1px solid #ddd; } blockquote:before { position: absolute; top: 10px; left: 10px; line-height: 1; /* Left double quote */ content: "\201C"; font-family: Georgia, serif; font-size: 60px; color: #455372; } /* メインページのモバイルビュー専用項目 */ .main-page-mobile-view { display: none; } /* wikitable/prettytable class for skinning normal tables */ table.prettytable { background: #f9f9f9; border: 1px solid #aaa; border-collapse: collapse; } table.prettytable th, table.prettytable td { border: 1px solid #aaa; padding: 0.2em; } table.prettytable th { background: #f2f2f2; text-align: center; } table.prettytable caption { margin-left: inherit; margin-right: inherit; } /* default skin for navigation boxes */ /* navbox container style */ table.navbox { box-sizing: border-box; border: 1px solid #aaa; width: 100%; margin: auto; clear: both; font-size: 88%; text-align: center; padding: 1px; } /* single pixel border between adjacent navboxes (doesn't work for IE6, but that's okay) */ table.navbox + table.navbox { margin-top: -1px; } /* title and above/below styles */ .navbox-title, .navbox-abovebelow, table.navbox th { text-align: center; padding-left: 1em; padding-right: 1em; } /* group style */ .navbox-group { white-space: nowrap; text-align: right; font-weight: bold; padding-left: 1em; padding-right: 1em; } /* Level 1 color */ .navbox-title, table.navbox th, .infobox-above { background: #ABD692; } /* Level 2 color */ .navbox-abovebelow, .navbox-group, .navbox-subgroup .navbox-title, .infobox-row th { background: #C3DEAD; } /* Level 3 color */ .navbox-subgroup .navbox-group, .navbox-subgroup .navbox-abovebelow { background: #E3E3E3; } /* Even row striping */ .navbox-even { background: #f7f7f7; } /* Odd row striping */ .navbox-odd { background: transparent; } /* [[MediaWiki:Common.js]] にある createCollapseButtons 関数を参照。 */ .collapseButton { float: right; font-weight: normal; text-align: right; width: auto; } /* [[Template:Navbox]] に配置する場合、左に配置されている [[Template:Tnavbar]] とのバランスを取る。 */ .navbox .collapseButton { width: 6em; } /* [[en:MediaWiki:Common.css]] から複製。 */ /* Style for horizontal lists (separator following item). Note: hlist formatting will break if the resulting HTML lacks a breakable character between list items. This happens when the following conditions are true: 1) The list is made using wiki markup (where HTML is built by parser.php) 2) HTMLTidy is disabled or unavailable (such as on Special: pages) In such cases, building lists with .hlist using HTML instead of wiki markup will work around this problem. See also [[Bugzilla:39617]]. IE8-specific classes are assigned in [[MediaWiki:Common.js/IEFixes.js]]. Last updated: January 24, 2013 @source mediawiki.org/wiki/Snippets/Horizontal_lists @maintainer: [[User:Edokter]] @revision: 3.1 */ .skin-monobook .hlist dl, .skin-modern .hlist dl, .skin-vector .hlist dl { line-height: 1.5em; } .hlist dl, .hlist ol, .hlist ul { margin: 0; padding: 0; } /* Display list items inline and make them nowrap */ .hlist dd, .hlist dt, .hlist li { margin: 0; display: inline; white-space: nowrap; } /* Allow wrapping for list items (in tight spaces) */ .hlist.hwrap dd, .hlist.hwrap dt, .hlist.hwrap li { white-space: normal; } /* Display nested lists inline and allow them to wrap */ .hlist dl dl, .hlist dl ol, .hlist dl ul, .hlist ol dl, .hlist ol ol, .hlist ol ul, .hlist ul dl, .hlist ul ol, .hlist ul ul { display: inline; white-space: normal; } /* Generate interpuncts */ .hlist dt:after { content: ":"; } .hlist dd:after, .hlist li:after { content: " ·"; font-weight: bold; } /* 日本語版の独自仕様。-pipe と -hyphen */ .hlist-pipe dd:after, .hlist-pipe li:after { content: " |"; font-weight: normal; } .hlist-hyphen dd:after, .hlist-hyphen li:after { content: " -"; font-weight: normal; } .hlist dd:last-child:after, .hlist dt:last-child:after, .hlist li:last-child:after { content: none; } /* For IE8 */ .hlist dd.hlist-last-child:after, .hlist dt.hlist-last-child:after, .hlist li.hlist-last-child:after { content: none; } /* Add parentheses around nested lists */ .hlist dd dd:first-child:before, .hlist dd dt:first-child:before, .hlist dd li:first-child:before, .hlist dt dd:first-child:before, .hlist dt dt:first-child:before, .hlist dt li:first-child:before, .hlist li dd:first-child:before, .hlist li dt:first-child:before, .hlist li li:first-child:before { content: "("; font-weight: normal; } .hlist dd dd:last-child:after, .hlist dd dt:last-child:after, .hlist dd li:last-child:after, .hlist dt dd:last-child:after, .hlist dt dt:last-child:after, .hlist dt li:last-child:after, .hlist li dd:last-child:after, .hlist li dt:last-child:after, .hlist li li:last-child:after { content: ")"; font-weight: normal; } /* For IE8 */ .hlist dd dd.hlist-last-child:after, .hlist dd dt.hlist-last-child:after, .hlist dd li.hlist-last-child:after, .hlist dt dd.hlist-last-child:after, .hlist dt dt.hlist-last-child:after, .hlist dt li.hlist-last-child:after, .hlist li dd.hlist-last-child:after, .hlist li dt.hlist-last-child:after, .hlist li li.hlist-last-child:after { content: ")"; font-weight: normal; } /* Put numbers in front of ordered list items */ .hlist.hnum ol { counter-reset: list-item; } .hlist.hnum ol > li { counter-increment: list-item; } .hlist.hnum ol > li:before { content: counter(list-item) ".\a0"; } .hlist.hnum dd ol > li:first-child:before, .hlist.hnum dt ol > li:first-child:before, .hlist.hnum li ol > li:first-child:before { content: "(" counter(list-item) " "; } /* Avoid elements from breaking between columns */ .nocolbreak, li, dd { -webkit-column-break-inside: avoid; page-break-inside: avoid; break-inside: avoid-column; } dt { -webkit-column-break-after: avoid; page-break-after: avoid; break-after: avoid-column; } dd { -webkit-column-break-before: avoid; page-break-before: avoid; break-before: avoid-column; } /* default skin for navigation boxes */ /* navbox container style */ table.navbox { box-sizing: border-box; border: 1px solid #aaa; width: 100%; margin: 1em 0; clear: both; font-size: 88%; text-align: center; padding: 1px; } /* single pixel border between adjacent navboxes (doesn't work for IE6, but that's okay) */ table.navbox + table.navbox { margin-top: -1px; } /* title and above/below styles */ .navbox-title, .navbox-abovebelow, table.navbox th { text-align: center; padding-left: 1em; padding-right: 1em; } /* group style */ .navbox-group { white-space: nowrap; text-align: right; font-weight: bold; padding-left: 1em; padding-right: 1em; } /* Style for "notices" */ .notice { text-align: justify; margin: 1em; padding: 0.2em; } #disambig { border-top: 3px double #ccc; border-bottom: 3px double #ccc; } #spoiler { border-top: 2px solid #ddd; border-bottom: 2px solid #ddd; } /* Standard talk template style */ .Talk-Notice { box-sizing: border-box; border: 1px solid #c0c090; background-color: #f8eaba; margin-bottom: 3px; width: 85%; border-spacing: 3px; margin-left: auto; margin-right: auto; } .Talk-Notice:after { content: "The CSS for this template should be changed. See [[Wikipedia:Template Standardisation]]." } /* Make template background appear correctly on all browsers */ .Talk-Notice td { background: inherit; } /* Metadata */ table.metadata { border: 1px solid #aaa; display: none; } .metadata-label { color: #aaa; } /* Add formatting to make sure that "external references" from [[Template:Ref]] do not get URL expansion, not even when printed. The mechanism up to MediaWiki 1.4 was that the HTML code contained a SPAN following the anchor A; this SPAN had the class "urlexpansion", which was not displayed on screen, but was shown when the medium was "print". The rules below ensure (a) that there is no extra padding to the right of the anchor (displayed as "[<number>]"), (b) that there is no "external link arrow" for the link, and (c) that this SPAN of class "urlexpansion" is never shown. ~~~~ */ .plainlinksneverexpand { background: none !important; padding: 0 !important; } .plainlinksneverexpand .urlexpansion { display: none !important; } /* Make sure that ext links displayed within "plainlinksneverexpand" don't get the arrow... */ .plainlinksneverexpand a { background: none !important; padding: 0 !important } /* With MediaWiki 1.5, the mechanism has changed: instead of a SPAN of class "urlexpansion" following the anchor A, the anchor itself now has class "external autonumber" and the expansion is inserted when printing (see the common printing style sheet at //en.wikipedia.org/skins-1.5/common/commonPrint.css) using the ":after" pseudo- element of CSS. We have to switch this off for links due to Template:Ref! ~~~~ */ .plainlinksneverexpand a.external.text:after { display: none !important; } .plainlinksneverexpand a.external.autonumber:after { display: none !important; } /* Merge template style */ .messagebox { box-sizing: border-box; border: 1px solid #aaa; background: #f9f9f9; width: 80%; margin: 0 auto 1em auto; padding: 0.2em; text-align: justify; } .messagebox.merge { box-sizing: border-box; border: 2px solid #033; width: 55%; background: #eff; padding: 1em; margin: 1em auto 1em auto; } .messagebox.cleanup { border: 1px solid #9f9fff; background: #efefff; text-align: center; } .messagebox.standard-talk { border: 1px solid #c0c090; background: #f8eaba; } .infobox { border: 1px solid #aaa; background-color: #f9f9f9; color: black; margin: 0.5em 0 0.5em 1em; padding: 0.2em; float: right; clear: right; text-align: left; font-size: 88%; line-height: 1.5em; } .infobox caption { margin-top: 0.5em; font-size: 125%; font-weight: bold; } .infobox td, .infobox th { padding: 0.2em; vertical-align: top; } .infobox.bordered { border-collapse: collapse; } .infobox.bordered td, .infobox.bordered th { border: 1px solid #aaa; } .infobox.bordered .borderless td, .infobox.bordered .borderless th { border: 0; } .infobox.sisterproject { width: 20em; font-size: 90%; } .infobox td > p, .infobox td > dl { margin: 0; } .infobox td ul { margin-top: 0; margin-left: 1.25em; } .infobox dd { margin-left: 1em; } #wpSave { font-weight: bold; } /* hiddenStructure from Monobook - allows selective hiding of markup in templates */ .hiddenStructure { display: none; speak: none; } /* Icons for medialist templates [[Template:Listen]], [[Template:Multi-listen_start]], [[Template:Video]], [[Template:Multi-video_start]] */ div.listenlist { background: url("//upload.wikimedia.org/wikipedia/commons/thumb/a/a6/Gnome-speakernotes.png/30px-Gnome-speakernotes.png"); padding-left: 40px; } div.videolist, div.multivideolist { background: url("//upload.wikimedia.org/wikipedia/en/thumb/2/20/Tango-video-x-generic.png/40px-Tango-video-x-generic.png"); padding-left: 50px; } /* Style rules for media list templates */ div.medialist { min-height: 50px; margin: 1em; background-position: top left; background-repeat: no-repeat; } div.medialist ul { list-style-type: none; list-style-image: none; margin: 0; } div.medialist ul li { padding-bottom: 0.5em; } div.medialist ul li li { font-size: 91%; padding-bottom: 0; } /************************/ /* CommonsTicker styles */ /************************/ /* links */ .tickerDiffLink { } /* diff links in ticker */ .tickerMiscLink { } /* misc links in ticker */ /* remove list bullets */ .tickerList ul, .tickerList ul li { list-style: none; text-indent: -2em; margin-left: 2em; text-align: left; } .tickerList ul ul, .tickerList ul ul li { list-style: none; text-indent: 0; margin-left: 1.5em; text-align: left; } /* per-type styles */ .tickerEntry_deleted { } /* entry for image deletion */ .tickerEntry_replaced { } /* entry for image replacement */ .tickerEntry_tagged { } /* entry for adding/removing problem tags */ .tickerEntry_redir { } /* entry for critical redirection (fot tag redirects) */ .tickerEntry_recat { } /* entry for critical re-categorization (for tag categories) */ .tickerEntry_notify { } /* entry for global notifications */ .tickerEntry_changed { } /* entry for generic change */ /* per-action styles */ .tickerAction_deleted:before { content: " GONE "; color: #FF0000; font-family: monospace; font-weight: bold; font-size: 100%; } .tickerAction_deletedRev:before { content: " -OLD "; color: #DDAAAA; font-family: monospace; font-weight: bold; font-size: 100%; } .tickerAction_replaced:before { content: " REPL "; color: #CC88FF; font-family: monospace; font-weight: bold; font-size: 100%; } .tickerAction_replacedOwn:before { content: " UPDT "; color: #EEAAFF; font-family: monospace; font-weight: bold; font-size: 100%; } .tickerAction_addedBad:before { content: " +VfD "; color: #FF8800; font-family: monospace; font-weight: bold; font-size: 100%; } .tickerAction_removedBad:before { content: " -VfD "; color: #00BB00; font-family: monospace; font-weight: bold; font-size: 100%; } .tickerAction_addedGood:before { content: " +OK "; color: #00BB00; font-family: monospace; font-weight: bold; font-size: 100%; } .tickerAction_removedGood:before { content: " -OK "; color: #FF8800; font-family: monospace; font-weight: bold; font-size: 100%; } /* ticker usage list */ .tickerUsage { font-size: 80%; } /* entry applies to a template used by multiple images */ .tickerTemplateEntry { font-weight: bold; } /* entry applies to sub-entries, i.e. images that use a specific template */ .tickerSubEntry { } /* minor entry styles */ /* minor entry */ .tickerMinorEntry { color: #666; } .tickerMinorEntry a, .tickerMinorEntry a:link, .tickerMinorEntry a:visited { color: #669; } #bodyContent .tickerMinorEntry a.extiw, #bodyContent .tickerMinorEntry a.extiw:link, #bodyContent .tickerMinorEntry a.extiw:visited { color: #669; } /* Change the external link icon to an Adobe icon anywhere the PDFlink class */ /* is used (notably Template: PDFlink). This works in IE, unlike the above. */ span.PDFlink a { background: url(//upload.wikimedia.org/wikipedia/commons/2/23/Icons-mini-file_acrobat.gif) center right no-repeat !important; padding-right: 17px !important; } /* ### nowrap for some table headings ### */ label[for="wpUserEmail"], label[for="wpNick"], label[for="wpUserLanguage"], label[for="wpOldpass"], label[for="wpNewpass"], label[for="wpRetypePass"], #userlogin2 label, #userloginForm label { white-space: nowrap } /* リダイレクトの表示 */ /* [[特別:Allpages]]・[[特別:Prefixindex]] */ .allpagesredirect a:link, .allpagesredirect a:visited, /* カテゴリ内 */ .redirect-in-category a:link, .redirect-in-category a:visited, /* ウォッチリスト */ .watchlistredir a:link, .watchlistredir a:visited { color: #666; } /* NavFrame関係。[[MediaWiki:Monobook.css]]も参照 */ div.Boxmerge, div.NavFrame { margin: 0; padding: 2px; border: 1px solid #aaaaaa; text-align: center; border-collapse: collapse; font-size: 95%; } div.Boxmerge div.NavFrame { border-style: none; border-style: hidden; } div.NavPic { background-color: #ffffff; margin: 0px; padding: 2px; float: left; } div.NavFrame div.NavHead { height: 1.6em; font-weight: bold; font-size: 100%; background-color: #efefef; position: relative; text-align: center; } div.NavFrame p { font-size: 100%; } div.NavFrame div.NavContent { font-size: 100%; } div.NavFrame div.NavContent p { font-size: 100%; } div.NavEnd { margin: 0px; padding: 0px; line-height: 1px; clear: both; } a.NavToggle { position: absolute; top: 0px; right: 3px; font-weight: normal; /* font-size: 83.3%;*/ } /* Article message box styles */ table.ambox { margin: 0 10%; /* 10% = 他の要素にはみ出るのを防ぐ */ border: 1px solid #aaa; border-left: 10px solid #1e90ff; /* 初期値: "notice" の青 */ background: #fbfbfb; } table.ambox + table.ambox { /* 重なったボックスの間を単一の罫線に */ margin-top: -1px; } .ambox th.mbox-text, .ambox td.mbox-text { /* メッセージ本体のセル */ padding: 0.25em 0.5em; /* 左右に 0.5em ずつの余白 */ } .ambox td.mbox-image { /* 左の画像セル */ padding: 2px 0 2px 0.5em; /* 左に 0.5em、右に 0px の余白 */ } .ambox td.mbox-imageright { /* 右の画像セル */ padding: 2px 0.5em 2px 0; /* 左に 0px、右に 0.5em の余白 */ } table.ambox-notice { border-left: 10px solid #1e90ff; /* 青 */ } table.ambox-speedy { border-left: 10px solid #b22222; /* 赤 */ background: #fee; /* 桃 */ } table.ambox-delete { border-left: 10px solid #b22222; /* 赤 */ } table.ambox-content { border-left: 10px solid #f28500; /* 橙 */ } table.ambox-style { border-left: 10px solid #f4c430; /* 黄 */ } table.ambox-move { border-left: 10px solid #9932cc; /* 紫 */ } table.ambox-protection { border-left: 10px solid #bba; /* 灰色・金色 */ } /* Cell sizes for ambox/tmbox/imbox/cmbox/ombox/fmbox/dmbox message boxes */ th.mbox-text, td.mbox-text { /* The message body cell(s) */ box-sizing: border-box; border: none; padding: 0.25em 0.9em; /* 0.9em left/right */ width: 100%; /* Make all mboxes the same width regardless of text length */ font-size: 90%; } td.mbox-image { /* The left image cell */ border: none; padding: 2px 0 2px 0.9em; /* 0.9em left, 0px right */ text-align: center; } td.mbox-imageright { /* The right image cell */ border: none; padding: 2px 0.9em 2px 0; /* 0px left, 0.9em right */ text-align: center; } td.mbox-empty-cell { /* An empty narrow cell */ border: none; padding: 0; width: 1px; } /* * [[MediaWiki:Revision-info]]、[[MediaWiki:Revision-info-current]]のフォントサイズ調整。 * 2010-07-15 by [[User:Penn Station]] */ #revision-info, #revision-info-current { font-size: small; margin-top: 4px; } /* ambox - 以下、日本語版の独自拡張 */ table.ambox div.ambox-imagecontainer { /* 画像セル内の画像表示領域 */ width: 52px; } table.ambox.ambox-section { /* 節用メッセージボックス */ margin: 0 10%; } table.ambox.ambox-section div.ambox-imagecontainer { width: 52px; } table.ambox.ambox-section th.mbox-text, table.ambox.ambox-section td.mbox-text { padding: 0.25em 0.5em; } /* Image message box styles */ table.imbox { margin: 4px 10%; border-collapse: collapse; border: 3px solid #1e90ff; /* Default "notice" blue */ background: #fbfbfb; } .imbox .mbox-text .imbox { /* For imboxes inside imbox-text cells. */ margin: 0 -0.5em; /* 0.9 - 0.5 = 0.4em left/right. */ } .mbox-inside .imbox { /* For imboxes inside other templates. */ margin: 4px; } table.imbox-notice { border: 3px solid #1e90ff; /* Blue */ } table.imbox-speedy { border: 3px solid #b22222; /* Red */ background: #fee; /* Pink */ } table.imbox-delete { border: 3px solid #b22222; /* Red */ } table.imbox-content { border: 3px solid #f28500; /* Orange */ } table.imbox-style { border: 3px solid #f4c430; /* Yellow */ } table.imbox-move { border: 3px solid #9932cc; /* Purple */ } table.imbox-protection { border: 3px solid #bba; /* Gray-gold */ } table.imbox-license { border: 3px solid #88a; /* Dark gray */ background: #f7f8ff; /* Light gray */ } table.imbox-featured { border: 3px solid #cba135; /* Brown-gold */ } /* Category message box styles */ table.cmbox { margin: 3px 10%; border-collapse: collapse; border: 1px solid #aaa; background: #DFE8FF; /* Default "notice" blue */ } table.cmbox-notice { background: #DFE8FF; /* Blue */ } table.cmbox-speedy { margin-top: 4px; margin-bottom: 4px; border: 4px solid #b22222; /* Red */ background: #FFDBDB; /* Pink */ } table.cmbox-delete { background: #FFDBDB; /* Red */ } table.cmbox-content { background: #FFE7CE; /* Orange */ } table.cmbox-style { background: #FFF9DB; /* Yellow */ } table.cmbox-move { background: #E4D8FF; /* Purple */ } table.cmbox-protection { background: #EFEFE1; /* Gray-gold */ } /* Other pages message box styles */ table.ombox { margin: 4px 10%; border-collapse: collapse; border: 1px solid #aaa; /* Default "notice" gray */ background: #f9f9f9; } table.ombox-notice { border: 1px solid #aaa; /* Gray */ } table.ombox-speedy { border: 2px solid #b22222; /* Red */ background: #fee; /* Pink */ } table.ombox-delete { border: 2px solid #b22222; /* Red */ } table.ombox-content { border: 1px solid #f28500; /* Orange */ } table.ombox-style { border: 1px solid #f4c430; /* Yellow */ } table.ombox-move { border: 1px solid #9932cc; /* Purple */ } table.ombox-protection { border: 2px solid #bba; /* Gray-gold */ } /* Talk page message box styles */ table.tmbox { margin: 4px 10%; border-collapse: collapse; border: 1px solid #c0c090; /* Default "notice" gray-brown */ background: #f8eaba; } .mediawiki .mbox-inside .tmbox { /* For tmboxes inside other templates. The "mediawiki" */ margin: 2px 0; /* class ensures that this declaration overrides other */ width: 100%; /* For Safari and Opera */ /* styles (including mbox-small above) */ } .mbox-inside .tmbox.mbox-small { /* "small" tmboxes should not be small when */ line-height: 1.5em; /* also "nested", so reset styles that are */ font-size: 100%; /* set in "mbox-small" above. */ } table.tmbox-speedy { border: 2px solid #b22222; /* Red */ background: #fee; /* Pink */ } table.tmbox-delete { border: 2px solid #b22222; /* Red */ } table.tmbox-content { border: 2px solid #f28500; /* Orange */ } table.tmbox-style { border: 2px solid #f4c430; /* Yellow */ } table.tmbox-move { border: 2px solid #9932cc; /* Purple */ } table.tmbox-protection, table.tmbox-notice { border: 1px solid #c0c090; /* Gray-brown */ } /* Disambig and set index box styles */ table.dmbox { clear: both; margin: 0.9em 1em; border-top: 1px solid #ccc; border-bottom: 1px solid #ccc; background: transparent; } /* Footer and header message box styles */ table.fmbox { clear: both; margin: 0.2em 0; width: 100%; border: 1px solid #aaa; background: #f9f9f9; /* Default "system" gray */ } table.fmbox-system { background: #f9f9f9; } table.fmbox-warning { border: 1px solid #bb7070; /* Dark pink */ background: #ffdbdb; /* Pink */ } table.fmbox-editnotice { background: transparent; } /* Div based "warning" style fmbox messages. */ div.mw-warning-with-logexcerpt, div.mw-lag-warn-high, div.mw-cascadeprotectedwarning, div#mw-protect-cascadeon { clear: both; margin: 0.2em 0; border: 1px solid #bb7070; background: #ffdbdb; padding: 0.25em 0.9em; } /* Div based "system" style fmbox messages. Used in [[MediaWiki:Noarticletext]] and [[MediaWiki:Readonly lag]]. */ div.mw-lag-warn-normal, div.noarticletext, div.fmbox-system { clear: both; margin: 0.2em 0; border: 1px solid #aaa; background: #f9f9f9; padding: 0.25em 0.9em; } /* These mbox-small classes must be placed after all other ambox/tmbox/ombox etc classes. "body.mediawiki" is so they override "table.ambox + table.ambox" above. */ body.mediawiki table.mbox-small { /* For the "small=yes" option. */ clear: right; float: right; margin: 4px 0 4px 1em; width: 238px; font-size: 88%; line-height: 1.25em; } body.mediawiki table.mbox-small-left { /* For the "small=left" option. */ margin: 4px 1em 4px 0; width: 238px; border-collapse: collapse; font-size: 88%; line-height: 1.25em; } /* [[Template: Pathnav]] */ .pathnavbox { clear: both; border: 1px outset #eef; padding: 0.3em 0.6em; margin: 0 0 0.5em 0; background-color: #eef; font-size: 90%; } .pathnavbox ul { list-style: none none; margin-top: 0; margin-bottom: 0; } .pathnavbox > ul { margin: 0; } .pathnavbox ul li { margin: 0; } /* 脚注ジャンプ先強調 */ ol.references > li:target { background-color: #DEF; } sup.reference:target { background-color: #DEF; } cite:target { background-color: #DEF; } /* Otheruses等の冒頭曖昧さ回避テンプレート */ .dablink { margin: 0.5em 0; padding: 3px 2em; background-color: transparent; border-bottom: 1px solid #aaa; font-size: 90%; } /* </source> */ 8fb992e8de56ef3c7a21ef9ed1fa2c0097a8e56c MediaWiki:Common.js 8 13 21 2019-01-31T14:06:40Z gundam>Ochaochaocha3 0 TYPE-MOON Wikiよりコピー javascript text/javascript /* ここにあるすべてのJavaScriptは、すべてのページ読み込みですべての利用者に対して読み込まれます */ /** * Collapsible tables ********************************************************* * * Description: Allows tables to be collapsed, showing only the header. See * [[Wikipedia:NavFrame]]. * Maintainers: [[User:R. Koot]] */ var autoCollapse = 2; var collapseCaption = "隠す"; var expandCaption = "表示"; window.collapseTable = function ( tableIndex ) { var Button = document.getElementById( 'collapseButton' + tableIndex ); var Table = document.getElementById( 'collapsibleTable' + tableIndex ); if ( !Table || !Button ) { return false; } var Rows = Table.rows; var i; if ( Button.firstChild.data === collapseCaption ) { for ( i = 1; i < Rows.length; i++ ) { Rows[i].style.display = 'none'; } Button.firstChild.data = expandCaption; } else { for ( i = 1; i < Rows.length; i++ ) { Rows[i].style.display = Rows[0].style.display; } Button.firstChild.data = collapseCaption; } }; function createCollapseButtons() { var tableIndex = 0; var NavigationBoxes = {}; var Tables = document.getElementsByTagName( 'table' ); var i; function handleButtonLink( index, e ) { window.collapseTable( index ); e.preventDefault(); } for ( i = 0; i < Tables.length; i++ ) { if ( $( Tables[i] ).hasClass( 'collapsible' ) ) { /* only add button and increment count if there is a header row to work with */ var HeaderRow = Tables[i].getElementsByTagName( 'tr' )[0]; if ( !HeaderRow ) continue; var Header = HeaderRow.getElementsByTagName( 'th' )[0]; if ( !Header ) continue; NavigationBoxes[ tableIndex ] = Tables[i]; Tables[i].setAttribute( 'id', 'collapsibleTable' + tableIndex ); var Button = document.createElement( 'span' ); var ButtonLink = document.createElement( 'a' ); var ButtonText = document.createTextNode( collapseCaption ); Button.className = 'collapseButton'; /* Styles are declared in Common.css */ ButtonLink.style.color = Header.style.color; ButtonLink.setAttribute( 'id', 'collapseButton' + tableIndex ); ButtonLink.setAttribute( 'href', '#' ); $( ButtonLink ).on( 'click', $.proxy( handleButtonLink, ButtonLink, tableIndex ) ); ButtonLink.appendChild( ButtonText ); Button.appendChild( document.createTextNode( '[' ) ); Button.appendChild( ButtonLink ); Button.appendChild( document.createTextNode( ']' ) ); Header.insertBefore( Button, Header.firstChild ); tableIndex++; } } for ( i = 0; i < tableIndex; i++ ) { if ( $( NavigationBoxes[i] ).hasClass( 'collapsed' ) || ( tableIndex >= autoCollapse && $( NavigationBoxes[i] ).hasClass( 'autocollapse' ) ) ) { window.collapseTable( i ); } else if ( $( NavigationBoxes[i] ).hasClass ( 'innercollapse' ) ) { var element = NavigationBoxes[i]; while ((element = element.parentNode)) { if ( $( element ).hasClass( 'outercollapse' ) ) { window.collapseTable ( i ); break; } } } } } mw.hook( 'wikipage.content' ).add( createCollapseButtons ); b2a84caf9cb353cb07fbecb33a9cbbb645d3c4f0 22 21 2019-06-23T13:26:46Z Ochaochaocha3 1 1版 をインポートしました javascript text/javascript /* ここにあるすべてのJavaScriptは、すべてのページ読み込みですべての利用者に対して読み込まれます */ /** * Collapsible tables ********************************************************* * * Description: Allows tables to be collapsed, showing only the header. See * [[Wikipedia:NavFrame]]. * Maintainers: [[User:R. Koot]] */ var autoCollapse = 2; var collapseCaption = "隠す"; var expandCaption = "表示"; window.collapseTable = function ( tableIndex ) { var Button = document.getElementById( 'collapseButton' + tableIndex ); var Table = document.getElementById( 'collapsibleTable' + tableIndex ); if ( !Table || !Button ) { return false; } var Rows = Table.rows; var i; if ( Button.firstChild.data === collapseCaption ) { for ( i = 1; i < Rows.length; i++ ) { Rows[i].style.display = 'none'; } Button.firstChild.data = expandCaption; } else { for ( i = 1; i < Rows.length; i++ ) { Rows[i].style.display = Rows[0].style.display; } Button.firstChild.data = collapseCaption; } }; function createCollapseButtons() { var tableIndex = 0; var NavigationBoxes = {}; var Tables = document.getElementsByTagName( 'table' ); var i; function handleButtonLink( index, e ) { window.collapseTable( index ); e.preventDefault(); } for ( i = 0; i < Tables.length; i++ ) { if ( $( Tables[i] ).hasClass( 'collapsible' ) ) { /* only add button and increment count if there is a header row to work with */ var HeaderRow = Tables[i].getElementsByTagName( 'tr' )[0]; if ( !HeaderRow ) continue; var Header = HeaderRow.getElementsByTagName( 'th' )[0]; if ( !Header ) continue; NavigationBoxes[ tableIndex ] = Tables[i]; Tables[i].setAttribute( 'id', 'collapsibleTable' + tableIndex ); var Button = document.createElement( 'span' ); var ButtonLink = document.createElement( 'a' ); var ButtonText = document.createTextNode( collapseCaption ); Button.className = 'collapseButton'; /* Styles are declared in Common.css */ ButtonLink.style.color = Header.style.color; ButtonLink.setAttribute( 'id', 'collapseButton' + tableIndex ); ButtonLink.setAttribute( 'href', '#' ); $( ButtonLink ).on( 'click', $.proxy( handleButtonLink, ButtonLink, tableIndex ) ); ButtonLink.appendChild( ButtonText ); Button.appendChild( document.createTextNode( '[' ) ); Button.appendChild( ButtonLink ); Button.appendChild( document.createTextNode( ']' ) ); Header.insertBefore( Button, Header.firstChild ); tableIndex++; } } for ( i = 0; i < tableIndex; i++ ) { if ( $( NavigationBoxes[i] ).hasClass( 'collapsed' ) || ( tableIndex >= autoCollapse && $( NavigationBoxes[i] ).hasClass( 'autocollapse' ) ) ) { window.collapseTable( i ); } else if ( $( NavigationBoxes[i] ).hasClass ( 'innercollapse' ) ) { var element = NavigationBoxes[i]; while ((element = element.parentNode)) { if ( $( element ).hasClass( 'outercollapse' ) ) { window.collapseTable ( i ); break; } } } } } mw.hook( 'wikipage.content' ).add( createCollapseButtons ); b2a84caf9cb353cb07fbecb33a9cbbb645d3c4f0 メインページ 0 1 1 2019-06-23T10:28:13Z MediaWiki default 0 wikitext text/x-wiki <strong>MediaWiki はインストール済みです。</strong> ウィキソフトウェアの使い方に関する情報は[https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents 利用者案内]を参照してください。 == はじめましょう == * [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Configuration_settings/ja 設定の一覧] * [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ/ja MediaWiki よくある質問と回答] * [https://lists.wikimedia.org/mailman/listinfo/mediawiki-announce MediaWiki リリース情報メーリングリスト] * [https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation/ja MediaWiki のあなたの言語へのローカライズ] * [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Combating_spam あなたのウィキでスパムと戦う方法を学ぶ] 201fa7543177836d00bb3f4e6c0310c644508311 11 1 2019-06-23T11:23:01Z Ochaochaocha3 1 Wikiの概要を示す wikitext text/x-wiki == ようこそ {{SITENAME}} へ == TRPGツールの開発や運用に関する情報をまとめるwikiです。TRPGのオンラインセッションに使われているツールの設置の仕方や使われている要素技術など、開発や運用に役立つ情報をまとめていきましょう。 現在、{{SITENAME}}には約 [[Special:Statistics|{{NUMBEROFARTICLES}}]] 本の記事があります。 [[Category:{{SITENAME}}]] {{DEFAULTSORT:めいんへえし}} 70ddfc26a04257bae3f1e7cfafb678fae44924a6 12 11 2019-06-23T11:55:55Z Ochaochaocha3 1 主要項目へのリンクを追加する wikitext text/x-wiki == ようこそ {{SITENAME}} へ == オープンソースのTRPGツールの開発や運用に関する情報をまとめるwikiです。TRPGのオンラインセッションに使われているツールの設置の仕方や使われている要素技術など、開発や運用に役立つ情報をまとめていきましょう。 現在、{{SITENAME}}には約 [[Special:Statistics|{{NUMBEROFARTICLES}}]] 本の記事があります。 == 主要なTRPGツール == === Webアプリケーション === * [[どどんとふ]] ** [[ひよんとふ]](ひよこどどんとふクライアント) * [[ユドナリウム]] * [[オンセンルーム]]([[TRPGオンラインセッションSNS]]) * [[ねこ卓]] * [[Quoridorn]] * [[Onset!]] * [[Saider]] * [[Saipage]] === ダイスボット === * [[BCDice]](ボーン&カーズ) ** [[BCDice-API]] ** [[discord-bcdicebot]] == 公開サーバー == * [[どどんとふ公式鯖]] * [[どどんとふむせる]] * [[コノスサーバー]] * [[TRPG.NET]] == チャットプラットフォーム == * [[Discord]] * [[IRC]] [[Category:{{SITENAME}}]] {{DEFAULTSORT:めいんへえし}} 8aebd619f22579610caca1887bf692cff21a0906 13 12 2019-06-23T11:56:36Z Ochaochaocha3 1 __NOTOC__を追加する wikitext text/x-wiki __NOTOC__ == ようこそ {{SITENAME}} へ == オープンソースのTRPGツールの開発や運用に関する情報をまとめるwikiです。TRPGのオンラインセッションに使われているツールの設置の仕方や使われている要素技術など、開発や運用に役立つ情報をまとめていきましょう。 現在、{{SITENAME}}には約 [[Special:Statistics|{{NUMBEROFARTICLES}}]] 本の記事があります。 == 主要なTRPGツール == === Webアプリケーション === * [[どどんとふ]] ** [[ひよんとふ]](ひよこどどんとふクライアント) * [[ユドナリウム]] * [[オンセンルーム]]([[TRPGオンラインセッションSNS]]) * [[ねこ卓]] * [[Quoridorn]] * [[Onset!]] * [[Saider]] * [[Saipage]] === ダイスボット === * [[BCDice]](ボーン&カーズ) ** [[BCDice-API]] ** [[discord-bcdicebot]] == 公開サーバー == * [[どどんとふ公式鯖]] * [[どどんとふむせる]] * [[コノスサーバー]] * [[TRPG.NET]] == チャットプラットフォーム == * [[Discord]] * [[IRC]] [[Category:{{SITENAME}}]] {{DEFAULTSORT:めいんへえし}} 6a2651a0ddb50abdfbb8a1648c6c78e6db9facaf 26 13 2019-06-23T14:09:39Z Ochaochaocha3 1 /* ダイスボット */ wikitext text/x-wiki __NOTOC__ == ようこそ {{SITENAME}} へ == オープンソースのTRPGツールの開発や運用に関する情報をまとめるwikiです。TRPGのオンラインセッションに使われているツールの設置の仕方や使われている要素技術など、開発や運用に役立つ情報をまとめていきましょう。 現在、{{SITENAME}}には約 [[Special:Statistics|{{NUMBEROFARTICLES}}]] 本の記事があります。 == 主要なTRPGツール == === Webアプリケーション === * [[どどんとふ]] ** [[ひよんとふ]](ひよこどどんとふクライアント) * [[ユドナリウム]] * [[オンセンルーム]]([[TRPGオンラインセッションSNS]]) * [[ねこ卓]] * [[Quoridorn]] * [[Onset!]] * [[Saider]] * [[Saipage]] === ダイスボット === * [[BCDice]](ボーンズ&カーズ) ** [[BCDice-API]] ** [[discord-bcdicebot]] == 公開サーバー == * [[どどんとふ公式鯖]] * [[どどんとふむせる]] * [[コノスサーバー]] * [[TRPG.NET]] == チャットプラットフォーム == * [[Discord]] * [[IRC]] [[Category:{{SITENAME}}]] {{DEFAULTSORT:めいんへえし}} 8c6ab3b7cf458a4a30ca4ff7e9b3264248368b87 テンプレート:FlowMention 10 2 3 2019-06-23T11:13:12Z Flow talk page manager 2 /* Automatically created by Flow */ wikitext text/x-wiki @[[利用者:{{{1|Example}}}|{{{2|{{{1|Example}}}}}}]] 28552144d847371f9fd923948d1b7e319fb3edb1 テンプレート:LQT Moved thread stub converted to Flow 10 3 4 2019-06-23T11:13:12Z Flow talk page manager 2 /* Automatically created by Flow */ wikitext text/x-wiki この投稿は{{{author}}}によって{{{date}}}上に移動されました。それを[[{{{title}}}]]で発見できます。 78052547237ca720ebacace011a106dda780c2e7 テンプレート:LQT page converted to Flow 10 4 5 2019-06-23T11:13:12Z Flow talk page manager 2 /* Automatically created by Flow */ wikitext text/x-wiki バックアップのため、以前のページの履歴は {{#time: Y-m-d|{{{date}}}}} に <span class='flow-link-to-archive'>[[{{{archive}}}]]</span> に保存されました。 d273c3ad4ab93cbf71951c8f7d10649c62446eee テンプレート:Archive for converted LQT page 10 5 6 2019-06-23T11:13:12Z Flow talk page manager 2 /* Automatically created by Flow */ wikitext text/x-wiki This page is an archived LiquidThreads page. <strong>Do not edit the contents of this page</strong>. Please direct any additional comments to the [[{{{from}}}|current talk page]]. 6f2232948be664f5eec18e4b7a6219814d38a478 テンプレート:LQT post imported with suppressed user 10 6 7 2019-06-23T11:13:12Z Flow talk page manager 2 /* Automatically created by Flow */ wikitext text/x-wiki This revision was imported from LiquidThreads with a suppressed user. It has been reassigned to the current user. 0eb25fe53f4e146ddc0b16b14bd40d6069e56c06 テンプレート:LQT post imported with different signature user 10 7 8 2019-06-23T11:13:12Z Flow talk page manager 2 /* Automatically created by Flow */ wikitext text/x-wiki <em>この投稿は [[User:{{{authorUser}}}|{{{authorUser}}}]] により投稿されましたが、[[User:{{{signatureUser}}}|{{{signatureUser}}}]] として署名されました。</em> 97c32cbacac57530c10252921450e9de1d9fe388 テンプレート:Wikitext talk page converted to Flow 10 8 9 2019-06-23T11:13:13Z Flow talk page manager 2 /* Automatically created by Flow */ wikitext text/x-wiki 以前の議論は、{{#time: Y-m-d|{{{date}}}}} に <span class='flow-link-to-archive'>[[{{{archive}}}]]</span> に保存されました。 2f263916ff4287a712fef941f1b88e9b1a8aff4f テンプレート:Archive for converted wikitext talk page 10 9 10 2019-06-23T11:13:13Z Flow talk page manager 2 /* Automatically created by Flow */ wikitext text/x-wiki このページはアーカイブです。<strong>決して、このページを編集しないでください</strong>。コメントを追加したい場合は、[[{{{from|{{TALKSPACE}}:{{BASEPAGENAME}}}}}|トークページ]]で行ってください。 33f4a9cbdabd8865a37bdb6ecbcea39744139aae どどんとふ 0 10 14 2019-06-23T12:11:33Z Ochaochaocha3 1 ページの作成:「'''どどんとふ'''は、たいたい竹流氏によって開発されたオンラインセッションツール。 * 公式サイト:[http://www.dodontof.com/ ど…」 wikitext text/x-wiki '''どどんとふ'''は、たいたい竹流氏によって開発されたオンラインセッションツール。 * 公式サイト:[http://www.dodontof.com/ どどんとふ@えくすとり~む] * 使用技術:Flash、Ruby == 概要 == <blockquote> 「どどんとふ」はTRPGのオンラインセッションをお手軽&楽しく遊ぶために作られたツールです。<br /> ブラウザだけで全ての操作が可能。<br /> マップ表示もキャラクター配置もチャットもイニシアティブ管理も、さらには動画や音楽の共有まで楽しめます。<br /> OSをほとんど気にせず動作します。WindowsでもMacでもUNIXでもOK。<br /> 「<cite>[http://www.dodontof.com/DodontoF/README.html 「どどんとふ」マニュアル]</cite>」より引用 </blockquote> [[Category:TRPGツール]] {{DEFAULTSORT:ととんとふ}} 4aeb0ecebae63974ac15efaddbb0e51752a064a2 15 14 2019-06-23T12:12:26Z Ochaochaocha3 1 GitHubリポジトリを追加する wikitext text/x-wiki '''どどんとふ'''は、たいたい竹流氏によって開発されたオンラインセッションツール。 * 公式サイト:[http://www.dodontof.com/ どどんとふ@えくすとり~む] * GitHubリポジトリ:[https://github.com/torgtaitai/DodontoF torgtaitai/DodontoF] * 使用技術:Flash、Ruby == 概要 == <blockquote> 「どどんとふ」はTRPGのオンラインセッションをお手軽&楽しく遊ぶために作られたツールです。<br /> ブラウザだけで全ての操作が可能。<br /> マップ表示もキャラクター配置もチャットもイニシアティブ管理も、さらには動画や音楽の共有まで楽しめます。<br /> OSをほとんど気にせず動作します。WindowsでもMacでもUNIXでもOK。<br /> 「<cite>[http://www.dodontof.com/DodontoF/README.html 「どどんとふ」マニュアル]</cite>」より引用 </blockquote> [[Category:TRPGツール]] {{DEFAULTSORT:ととんとふ}} 81788d02a56ad2f262a96e616cd74f5573d94889 16 15 2019-06-23T12:27:08Z Ochaochaocha3 1 機能を列挙する wikitext text/x-wiki '''どどんとふ'''は、たいたい竹流氏によって開発されたオンラインセッションツール。 * 公式サイト:[http://www.dodontof.com/ どどんとふ@えくすとり~む] * GitHubリポジトリ:[https://github.com/torgtaitai/DodontoF torgtaitai/DodontoF] * 使用技術:Flash、Ruby == 概要 == <blockquote> 「どどんとふ」はTRPGのオンラインセッションをお手軽&楽しく遊ぶために作られたツールです。<br /> ブラウザだけで全ての操作が可能。<br /> マップ表示もキャラクター配置もチャットもイニシアティブ管理も、さらには動画や音楽の共有まで楽しめます。<br /> OSをほとんど気にせず動作します。WindowsでもMacでもUNIXでもOK。<br /> 「<cite>[http://www.dodontof.com/DodontoF/README.html 「どどんとふ」マニュアル]</cite>」より引用 </blockquote> オンラインセッションに必要な多くの機能を備えた総合オンラインセッションツール。部屋の作成、チャット、ダイスボット、キャラクター管理、マップ管理、イニシアティブ表といった基本的な機能に加えて、以下のような豊富な機能を搭載している。 * 秘話チャット * シークレットダイス * ダイスシンボル * 共有メモ * カード * 資源管理 * 範囲 * 魔法タイマー * チット設置 * マップ手書き * 画像のアップロード * Webカメラ撮影 * 立ち絵 * ノベルゲーム風表示 * カットイン * 読み上げ * リプレイ録画 * 多言語対応 [[Category:TRPGツール]] {{DEFAULTSORT:ととんとふ}} f2ed891594e837cea9c8f47738499bd2af1a34f8 18 16 2019-06-23T13:03:45Z Ochaochaocha3 1 スクリーンショットを追加する wikitext text/x-wiki [[ファイル:dodontof-screenshot.png|サムネイル|どどんとふのスクリーンショット]] '''どどんとふ'''は、たいたい竹流氏によって開発されたオンラインセッションツール。 * 公式サイト:[http://www.dodontof.com/ どどんとふ@えくすとり~む] * GitHubリポジトリ:[https://github.com/torgtaitai/DodontoF torgtaitai/DodontoF] * 使用技術:Flash、Ruby == 概要 == <blockquote> 「どどんとふ」はTRPGのオンラインセッションをお手軽&楽しく遊ぶために作られたツールです。<br /> ブラウザだけで全ての操作が可能。<br /> マップ表示もキャラクター配置もチャットもイニシアティブ管理も、さらには動画や音楽の共有まで楽しめます。<br /> OSをほとんど気にせず動作します。WindowsでもMacでもUNIXでもOK。<br /> 「<cite>[http://www.dodontof.com/DodontoF/README.html 「どどんとふ」マニュアル]</cite>」より引用 </blockquote> オンラインセッションに必要な多くの機能を備えた総合オンラインセッションツール。部屋の作成、チャット、ダイスボット、キャラクター管理、マップ管理、イニシアティブ表といった基本的な機能に加えて、以下のような豊富な機能を搭載している。 * 秘話チャット * シークレットダイス * ダイスシンボル * 共有メモ * カード * 資源管理 * 範囲 * 魔法タイマー * チット設置 * マップ手書き * 画像のアップロード * Webカメラ撮影 * 立ち絵 * ノベルゲーム風表示 * カットイン * 読み上げ * リプレイ録画 * 多言語対応 [[Category:TRPGツール]] {{DEFAULTSORT:ととんとふ}} 51a2c0f421ac927d488dda9d0b560e58684233b5 23 18 2019-06-23T13:59:38Z Ochaochaocha3 1 設置手順を追記する wikitext text/x-wiki [[ファイル:dodontof-screenshot.png|サムネイル|どどんとふのスクリーンショット]] '''どどんとふ'''は、たいたい竹流氏によって開発されたオンラインセッションツール。 * 公式サイト:[http://www.dodontof.com/ どどんとふ@えくすとり~む] * GitHubリポジトリ:[https://github.com/torgtaitai/DodontoF torgtaitai/DodontoF] * 使用技術:Flash、Ruby == 概要 == <blockquote> 「どどんとふ」はTRPGのオンラインセッションをお手軽&楽しく遊ぶために作られたツールです。<br /> ブラウザだけで全ての操作が可能。<br /> マップ表示もキャラクター配置もチャットもイニシアティブ管理も、さらには動画や音楽の共有まで楽しめます。<br /> OSをほとんど気にせず動作します。WindowsでもMacでもUNIXでもOK。<br /> 「<cite>[http://www.dodontof.com/DodontoF/README.html 「どどんとふ」マニュアル]</cite>」より引用 </blockquote> オンラインセッションに必要な多くの機能を備えた総合オンラインセッションツール。部屋の作成、チャット、ダイスボット、キャラクター管理、マップ管理、イニシアティブ表といった基本的な機能に加えて、以下のような豊富な機能を搭載している。 * 秘話チャット * シークレットダイス * ダイスシンボル * 共有メモ * カード * 資源管理 * 範囲 * 魔法タイマー * チット設置 * マップ手書き * 画像のアップロード * Webカメラ撮影 * 立ち絵 * ノベルゲーム風表示 * カットイン * 読み上げ * リプレイ録画 * 多言語対応 == 設置 == === 小規模サーバー === 少人数で使用する場合は、[[Ruby]](1.8.7以上)が使えるレンタルサーバーにファイルを置き、パーミッションの設定をするだけでよい。マニュアルでは、さくらインターネットのレンタルサーバー([https://www.sakura.ne.jp/ さくらのレンタルサーバ])が推奨されている。 まず、公式サイトの[http://www.dodontof.com/index.php?option=com_content&view=article&id=246&Itemid=126 ダウンロードページ]から最新版または安定版のzipファイルをダウンロードし、展開する。さくらのレンタルサーバでアカウント名が「trpg_net」の場合、展開したファイルを以下のように配置し、パーミッションを設定する。 <pre> home +- trpg_net +- www | +- DodontoF (705) | | +- DodontoFServer.rb (705) | | +- log.txt (600) | | +- log.txt.0 (600) | | +- saveDataTempSpace (705) | | +- fileUploadSpace (705) | | +- replayDataUploadSpace (705) | +- imageUploadSpace (705) | +- smallImages (705) +- saveData (705) </pre> ファイルの配置およびパーミッション設定が完了したら、ブラウザから <code>DodontoF/DodontoFServer.rb</code> を開く。上記の例の場合、URLは <pre>http://trpg_net.sakura.ne.jp/DodontoF/DodontoFServer.rb</pre> となる。ファイルの配置およびパーミッション設定が正しくできていれば、以下のように表示される。 <syntaxhighlight lang="json"> ["「どどんとふ」の動作環境は正常に起動しています。"] </syntaxhighlight> 上記のメッセージが表示されたら、<code>DodontoF/DodontoF.swf</code> を開く。上記の例の場合、URLは <pre>http://trpg_net.sakura.ne.jp/DodontoF/DodontoF.swf</pre> となる。 === 大規模サーバー === レンタルサーバーを使う場合、快適に使用できる人数は10人程度までであり、それ以上の人数では負荷が重くなる。大規模なサーバーでは、以下のような構成とする例が多い。 * より高性能なサーバーやVPSを使う。 ** SSDを使う。 ** メモリに余裕があれば、RAMディスクを使う。 ** 必要に応じて、TCP/IPに関するLinuxカーネルのチューニングを行う。 * Webサーバーとしてnginxを使う。 * 最新のRubyを使う。 * FastCGIを使う。 ** spawn-fcgiなどでサーバープログラムを起動する。 ** Gem「fcgi」を使う。 * Gem「msgpack」を使う。 * 擬似cometモードを使わない。 設置の手順を解説している記事として、以下のものがある。 * [http://cre.jp/techblog/2016/01/27/dodontof-centos7-nginx-spawn/ クリエイターズネットワーク技術部ブログ » CentOS7+nginx+spawn-fcgi でどどんとふを動かす] ** [[TRPG.NET]]へのどどんとふの設置時の作業を基にしている。 * 大ちゃんのいろいろ雑記 - どどんとふをdebian+nginxで動かすやり方(nginxセットアップ編)@公式鯖3rdシリーズ ** [[どどんとふ公式鯖]]へのどどんとふ設置作業の記録。ハードウェアの性能を満たすのは難しいが、各要素は参考になる。 *# [https://www.taruki.com/wp/?p=6099 OS編] *# [https://www.taruki.com/wp/?p=6123 nginxセットアップ編] *# [https://www.taruki.com/wp/?p=6133 fcgi編] *# [https://www.taruki.com/wp/?p=6160 どどんとふ本体編] *# [https://www.taruki.com/wp/?p=6162 運用ツール編(最低限)] *# [https://www.taruki.com/wp/?p=6165 運用ツール編(その他)] *# [https://www.taruki.com/wp/?p=6182 運用ツール編(負荷グラフ)] [[Category:TRPGツール]] {{DEFAULTSORT:ととんとふ}} 55a33a7b7eb8fe155c5713b1d79165857212c60f 24 23 2019-06-23T14:01:10Z Ochaochaocha3 1 公式マニュアルを追加する wikitext text/x-wiki [[ファイル:dodontof-screenshot.png|サムネイル|どどんとふのスクリーンショット]] '''どどんとふ'''は、たいたい竹流氏によって開発されたオンラインセッションツール。 * 公式サイト:[http://www.dodontof.com/ どどんとふ@えくすとり~む] * 公式マニュアル:[http://www.melonbooks.com/index.php?main_page=product_info&products_id=IT0000197863 どどんとふで始める初めてのオンラインセッション2017年夏の号!] * GitHubリポジトリ:[https://github.com/torgtaitai/DodontoF torgtaitai/DodontoF] * 使用技術:Flash、Ruby == 概要 == <blockquote> 「どどんとふ」はTRPGのオンラインセッションをお手軽&楽しく遊ぶために作られたツールです。<br /> ブラウザだけで全ての操作が可能。<br /> マップ表示もキャラクター配置もチャットもイニシアティブ管理も、さらには動画や音楽の共有まで楽しめます。<br /> OSをほとんど気にせず動作します。WindowsでもMacでもUNIXでもOK。<br /> 「<cite>[http://www.dodontof.com/DodontoF/README.html 「どどんとふ」マニュアル]</cite>」より引用 </blockquote> オンラインセッションに必要な多くの機能を備えた総合オンラインセッションツール。部屋の作成、チャット、ダイスボット、キャラクター管理、マップ管理、イニシアティブ表といった基本的な機能に加えて、以下のような豊富な機能を搭載している。 * 秘話チャット * シークレットダイス * ダイスシンボル * 共有メモ * カード * 資源管理 * 範囲 * 魔法タイマー * チット設置 * マップ手書き * 画像のアップロード * Webカメラ撮影 * 立ち絵 * ノベルゲーム風表示 * カットイン * 読み上げ * リプレイ録画 * 多言語対応 == 設置 == === 小規模サーバー === 少人数で使用する場合は、[[Ruby]](1.8.7以上)が使えるレンタルサーバーにファイルを置き、パーミッションの設定をするだけでよい。マニュアルでは、さくらインターネットのレンタルサーバー([https://www.sakura.ne.jp/ さくらのレンタルサーバ])が推奨されている。 まず、公式サイトの[http://www.dodontof.com/index.php?option=com_content&view=article&id=246&Itemid=126 ダウンロードページ]から最新版または安定版のzipファイルをダウンロードし、展開する。さくらのレンタルサーバでアカウント名が「trpg_net」の場合、展開したファイルを以下のように配置し、パーミッションを設定する。 <pre> home +- trpg_net +- www | +- DodontoF (705) | | +- DodontoFServer.rb (705) | | +- log.txt (600) | | +- log.txt.0 (600) | | +- saveDataTempSpace (705) | | +- fileUploadSpace (705) | | +- replayDataUploadSpace (705) | +- imageUploadSpace (705) | +- smallImages (705) +- saveData (705) </pre> ファイルの配置およびパーミッション設定が完了したら、ブラウザから <code>DodontoF/DodontoFServer.rb</code> を開く。上記の例の場合、URLは <pre>http://trpg_net.sakura.ne.jp/DodontoF/DodontoFServer.rb</pre> となる。ファイルの配置およびパーミッション設定が正しくできていれば、以下のように表示される。 <syntaxhighlight lang="json"> ["「どどんとふ」の動作環境は正常に起動しています。"] </syntaxhighlight> 上記のメッセージが表示されたら、<code>DodontoF/DodontoF.swf</code> を開く。上記の例の場合、URLは <pre>http://trpg_net.sakura.ne.jp/DodontoF/DodontoF.swf</pre> となる。 === 大規模サーバー === レンタルサーバーを使う場合、快適に使用できる人数は10人程度までであり、それ以上の人数では負荷が重くなる。大規模なサーバーでは、以下のような構成とする例が多い。 * より高性能なサーバーやVPSを使う。 ** SSDを使う。 ** メモリに余裕があれば、RAMディスクを使う。 ** 必要に応じて、TCP/IPに関するLinuxカーネルのチューニングを行う。 * Webサーバーとしてnginxを使う。 * 最新のRubyを使う。 * FastCGIを使う。 ** spawn-fcgiなどでサーバープログラムを起動する。 ** Gem「fcgi」を使う。 * Gem「msgpack」を使う。 * 擬似cometモードを使わない。 設置の手順を解説している記事として、以下のものがある。 * [http://cre.jp/techblog/2016/01/27/dodontof-centos7-nginx-spawn/ クリエイターズネットワーク技術部ブログ » CentOS7+nginx+spawn-fcgi でどどんとふを動かす] ** [[TRPG.NET]]へのどどんとふの設置時の作業を基にしている。 * 大ちゃんのいろいろ雑記 - どどんとふをdebian+nginxで動かすやり方(nginxセットアップ編)@公式鯖3rdシリーズ ** [[どどんとふ公式鯖]]へのどどんとふ設置作業の記録。ハードウェアの性能を満たすのは難しいが、各要素は参考になる。 *# [https://www.taruki.com/wp/?p=6099 OS編] *# [https://www.taruki.com/wp/?p=6123 nginxセットアップ編] *# [https://www.taruki.com/wp/?p=6133 fcgi編] *# [https://www.taruki.com/wp/?p=6160 どどんとふ本体編] *# [https://www.taruki.com/wp/?p=6162 運用ツール編(最低限)] *# [https://www.taruki.com/wp/?p=6165 運用ツール編(その他)] *# [https://www.taruki.com/wp/?p=6182 運用ツール編(負荷グラフ)] [[Category:TRPGツール]] {{DEFAULTSORT:ととんとふ}} 0bcee11b5f2eb394c84d75d1b8234de10d8a8333 25 24 2019-06-23T14:01:44Z Ochaochaocha3 1 リンクを設定する wikitext text/x-wiki [[ファイル:dodontof-screenshot.png|サムネイル|どどんとふのスクリーンショット]] '''どどんとふ'''は、たいたい竹流氏によって開発されたオンラインセッションツール。 * 公式サイト:[http://www.dodontof.com/ どどんとふ@えくすとり~む] * 公式マニュアル:[http://www.melonbooks.com/index.php?main_page=product_info&products_id=IT0000197863 どどんとふで始める初めてのオンラインセッション2017年夏の号!] * GitHubリポジトリ:[https://github.com/torgtaitai/DodontoF torgtaitai/DodontoF] * 使用技術:[[Flash]]、[[Ruby]] == 概要 == <blockquote> 「どどんとふ」はTRPGのオンラインセッションをお手軽&楽しく遊ぶために作られたツールです。<br /> ブラウザだけで全ての操作が可能。<br /> マップ表示もキャラクター配置もチャットもイニシアティブ管理も、さらには動画や音楽の共有まで楽しめます。<br /> OSをほとんど気にせず動作します。WindowsでもMacでもUNIXでもOK。<br /> 「<cite>[http://www.dodontof.com/DodontoF/README.html 「どどんとふ」マニュアル]</cite>」より引用 </blockquote> オンラインセッションに必要な多くの機能を備えた総合オンラインセッションツール。部屋の作成、チャット、ダイスボット、キャラクター管理、マップ管理、イニシアティブ表といった基本的な機能に加えて、以下のような豊富な機能を搭載している。 * 秘話チャット * シークレットダイス * ダイスシンボル * 共有メモ * カード * 資源管理 * 範囲 * 魔法タイマー * チット設置 * マップ手書き * 画像のアップロード * Webカメラ撮影 * 立ち絵 * ノベルゲーム風表示 * カットイン * 読み上げ * リプレイ録画 * 多言語対応 == 設置 == === 小規模サーバー === 少人数で使用する場合は、[[Ruby]](1.8.7以上)が使えるレンタルサーバーにファイルを置き、パーミッションの設定をするだけでよい。マニュアルでは、さくらインターネットのレンタルサーバー([https://www.sakura.ne.jp/ さくらのレンタルサーバ])が推奨されている。 まず、公式サイトの[http://www.dodontof.com/index.php?option=com_content&view=article&id=246&Itemid=126 ダウンロードページ]から最新版または安定版のzipファイルをダウンロードし、展開する。さくらのレンタルサーバでアカウント名が「trpg_net」の場合、展開したファイルを以下のように配置し、パーミッションを設定する。 <pre> home +- trpg_net +- www | +- DodontoF (705) | | +- DodontoFServer.rb (705) | | +- log.txt (600) | | +- log.txt.0 (600) | | +- saveDataTempSpace (705) | | +- fileUploadSpace (705) | | +- replayDataUploadSpace (705) | +- imageUploadSpace (705) | +- smallImages (705) +- saveData (705) </pre> ファイルの配置およびパーミッション設定が完了したら、ブラウザから <code>DodontoF/DodontoFServer.rb</code> を開く。上記の例の場合、URLは <pre>http://trpg_net.sakura.ne.jp/DodontoF/DodontoFServer.rb</pre> となる。ファイルの配置およびパーミッション設定が正しくできていれば、以下のように表示される。 <syntaxhighlight lang="json"> ["「どどんとふ」の動作環境は正常に起動しています。"] </syntaxhighlight> 上記のメッセージが表示されたら、<code>DodontoF/DodontoF.swf</code> を開く。上記の例の場合、URLは <pre>http://trpg_net.sakura.ne.jp/DodontoF/DodontoF.swf</pre> となる。 === 大規模サーバー === レンタルサーバーを使う場合、快適に使用できる人数は10人程度までであり、それ以上の人数では負荷が重くなる。大規模なサーバーでは、以下のような構成とする例が多い。 * より高性能なサーバーやVPSを使う。 ** SSDを使う。 ** メモリに余裕があれば、RAMディスクを使う。 ** 必要に応じて、TCP/IPに関するLinuxカーネルのチューニングを行う。 * Webサーバーとしてnginxを使う。 * 最新のRubyを使う。 * FastCGIを使う。 ** spawn-fcgiなどでサーバープログラムを起動する。 ** Gem「fcgi」を使う。 * Gem「msgpack」を使う。 * 擬似cometモードを使わない。 設置の手順を解説している記事として、以下のものがある。 * [http://cre.jp/techblog/2016/01/27/dodontof-centos7-nginx-spawn/ クリエイターズネットワーク技術部ブログ » CentOS7+nginx+spawn-fcgi でどどんとふを動かす] ** [[TRPG.NET]]へのどどんとふの設置時の作業を基にしている。 * 大ちゃんのいろいろ雑記 - どどんとふをdebian+nginxで動かすやり方(nginxセットアップ編)@公式鯖3rdシリーズ ** [[どどんとふ公式鯖]]へのどどんとふ設置作業の記録。ハードウェアの性能を満たすのは難しいが、各要素は参考になる。 *# [https://www.taruki.com/wp/?p=6099 OS編] *# [https://www.taruki.com/wp/?p=6123 nginxセットアップ編] *# [https://www.taruki.com/wp/?p=6133 fcgi編] *# [https://www.taruki.com/wp/?p=6160 どどんとふ本体編] *# [https://www.taruki.com/wp/?p=6162 運用ツール編(最低限)] *# [https://www.taruki.com/wp/?p=6165 運用ツール編(その他)] *# [https://www.taruki.com/wp/?p=6182 運用ツール編(負荷グラフ)] [[Category:TRPGツール]] {{DEFAULTSORT:ととんとふ}} f24618f4c44f5b388d966fbf177e2067725f7b32 27 25 2019-06-23T14:11:30Z Ochaochaocha3 1 ダイスボットについて追記する wikitext text/x-wiki [[ファイル:dodontof-screenshot.png|サムネイル|どどんとふのスクリーンショット]] '''どどんとふ'''は、たいたい竹流氏によって開発されたオンラインセッションツール。 * 公式サイト:[http://www.dodontof.com/ どどんとふ@えくすとり~む] * 公式マニュアル:[http://www.melonbooks.com/index.php?main_page=product_info&products_id=IT0000197863 どどんとふで始める初めてのオンラインセッション2017年夏の号!] * GitHubリポジトリ:[https://github.com/torgtaitai/DodontoF torgtaitai/DodontoF] * 使用技術:[[Flash]]、[[Ruby]] == 概要 == <blockquote> 「どどんとふ」はTRPGのオンラインセッションをお手軽&楽しく遊ぶために作られたツールです。<br /> ブラウザだけで全ての操作が可能。<br /> マップ表示もキャラクター配置もチャットもイニシアティブ管理も、さらには動画や音楽の共有まで楽しめます。<br /> OSをほとんど気にせず動作します。WindowsでもMacでもUNIXでもOK。<br /> 「<cite>[http://www.dodontof.com/DodontoF/README.html 「どどんとふ」マニュアル]</cite>」より引用 </blockquote> オンラインセッションに必要な多くの機能を備えた総合オンラインセッションツール。部屋の作成、チャット、ダイスボット、キャラクター管理、マップ管理、イニシアティブ表といった基本的な機能に加えて、以下のような豊富な機能を搭載している。 * 秘話チャット * シークレットダイス * ダイスシンボル * 共有メモ * カード * 資源管理 * 範囲 * 魔法タイマー * チット設置 * マップ手書き * 画像のアップロード * Webカメラ撮影 * 立ち絵 * ノベルゲーム風表示 * カットイン * 読み上げ * リプレイ録画 * 多言語対応 === ダイスボット === ダイスボットとして[[BCDice]](ボーンズ&カーズ)を使用している。現在のBCDiceは、どどんとふ環境で動作することを前提として開発、テストされている。様々なゲームシステムのダイスロールおよび表引きに加え、独自の表の追加、カード機能などBCDiceの機能をフル活用しているのは、どどんとふならではである。 == 設置 == === 小規模サーバー === 少人数で使用する場合は、[[Ruby]](1.8.7以上)が使えるレンタルサーバーにファイルを置き、パーミッションの設定をするだけでよい。マニュアルでは、さくらインターネットのレンタルサーバー([https://www.sakura.ne.jp/ さくらのレンタルサーバ])が推奨されている。 まず、公式サイトの[http://www.dodontof.com/index.php?option=com_content&view=article&id=246&Itemid=126 ダウンロードページ]から最新版または安定版のzipファイルをダウンロードし、展開する。さくらのレンタルサーバでアカウント名が「trpg_net」の場合、展開したファイルを以下のように配置し、パーミッションを設定する。 <pre> home +- trpg_net +- www | +- DodontoF (705) | | +- DodontoFServer.rb (705) | | +- log.txt (600) | | +- log.txt.0 (600) | | +- saveDataTempSpace (705) | | +- fileUploadSpace (705) | | +- replayDataUploadSpace (705) | +- imageUploadSpace (705) | +- smallImages (705) +- saveData (705) </pre> ファイルの配置およびパーミッション設定が完了したら、ブラウザから <code>DodontoF/DodontoFServer.rb</code> を開く。上記の例の場合、URLは <pre>http://trpg_net.sakura.ne.jp/DodontoF/DodontoFServer.rb</pre> となる。ファイルの配置およびパーミッション設定が正しくできていれば、以下のように表示される。 <syntaxhighlight lang="json"> ["「どどんとふ」の動作環境は正常に起動しています。"] </syntaxhighlight> 上記のメッセージが表示されたら、<code>DodontoF/DodontoF.swf</code> を開く。上記の例の場合、URLは <pre>http://trpg_net.sakura.ne.jp/DodontoF/DodontoF.swf</pre> となる。 === 大規模サーバー === レンタルサーバーを使う場合、快適に使用できる人数は10人程度までであり、それ以上の人数では負荷が重くなる。大規模なサーバーでは、以下のような構成とする例が多い。 * より高性能なサーバーやVPSを使う。 ** SSDを使う。 ** メモリに余裕があれば、RAMディスクを使う。 ** 必要に応じて、TCP/IPに関するLinuxカーネルのチューニングを行う。 * Webサーバーとしてnginxを使う。 * 最新のRubyを使う。 * FastCGIを使う。 ** spawn-fcgiなどでサーバープログラムを起動する。 ** Gem「fcgi」を使う。 * Gem「msgpack」を使う。 * 擬似cometモードを使わない。 設置の手順を解説している記事として、以下のものがある。 * [http://cre.jp/techblog/2016/01/27/dodontof-centos7-nginx-spawn/ クリエイターズネットワーク技術部ブログ » CentOS7+nginx+spawn-fcgi でどどんとふを動かす] ** [[TRPG.NET]]へのどどんとふの設置時の作業を基にしている。 * 大ちゃんのいろいろ雑記 - どどんとふをdebian+nginxで動かすやり方(nginxセットアップ編)@公式鯖3rdシリーズ ** [[どどんとふ公式鯖]]へのどどんとふ設置作業の記録。ハードウェアの性能を満たすのは難しいが、各要素は参考になる。 *# [https://www.taruki.com/wp/?p=6099 OS編] *# [https://www.taruki.com/wp/?p=6123 nginxセットアップ編] *# [https://www.taruki.com/wp/?p=6133 fcgi編] *# [https://www.taruki.com/wp/?p=6160 どどんとふ本体編] *# [https://www.taruki.com/wp/?p=6162 運用ツール編(最低限)] *# [https://www.taruki.com/wp/?p=6165 運用ツール編(その他)] *# [https://www.taruki.com/wp/?p=6182 運用ツール編(負荷グラフ)] [[Category:TRPGツール]] {{DEFAULTSORT:ととんとふ}} 5b31b800fb445fcd5dfae2ea63f008803217e81e 28 27 2019-06-23T14:28:37Z Ochaochaocha3 1 /* Flashの廃止に伴う影響 */ wikitext text/x-wiki [[ファイル:dodontof-screenshot.png|サムネイル|どどんとふのスクリーンショット]] '''どどんとふ'''は、たいたい竹流氏によって開発されたオンラインセッションツール。 * 公式サイト:[http://www.dodontof.com/ どどんとふ@えくすとり~む] * 公式マニュアル:[http://www.melonbooks.com/index.php?main_page=product_info&products_id=IT0000197863 どどんとふで始める初めてのオンラインセッション2017年夏の号!] * GitHubリポジトリ:[https://github.com/torgtaitai/DodontoF torgtaitai/DodontoF] * 使用技術:[[Flash]]、[[Ruby]] == 概要 == <blockquote> 「どどんとふ」はTRPGのオンラインセッションをお手軽&楽しく遊ぶために作られたツールです。<br /> ブラウザだけで全ての操作が可能。<br /> マップ表示もキャラクター配置もチャットもイニシアティブ管理も、さらには動画や音楽の共有まで楽しめます。<br /> OSをほとんど気にせず動作します。WindowsでもMacでもUNIXでもOK。<br /> 「<cite>[http://www.dodontof.com/DodontoF/README.html 「どどんとふ」マニュアル]</cite>」より引用 </blockquote> オンラインセッションに必要な多くの機能を備えた、総合オンラインセッションツール。部屋の作成、チャット、ダイスボット、キャラクター管理、マップ管理、イニシアティブ表といった基本的な機能に加えて、以下のような豊富な機能を搭載している。 * 秘話チャット * シークレットダイス * ダイスシンボル * 共有メモ * カード * 資源管理 * 範囲 * 魔法タイマー * チット設置 * マップ手書き * 画像のアップロード * Webカメラ撮影 * 立ち絵 * ノベルゲーム風表示 * カットイン * 読み上げ * リプレイ録画 * 多言語対応 === ダイスボット === ダイスボットとして[[BCDice]](ボーンズ&カーズ)を使用している。現在のBCDiceは、どどんとふ環境で動作することを前提として開発、テストされている。様々なゲームシステムのダイスロールおよび表引きに加え、独自の表の追加、カード機能などBCDiceの機能をフル活用しているのは、どどんとふならではである。 == Flashの廃止に伴う影響 == どどんとふのクライアントプログラム(プレイヤーが操作する画面のプログラム)は、[[Flash]]を使用して作られている。Flashは2020年に廃止されることが決定しており、2021年以降、通常はブラウザからクライアントプログラムを動作させることができなくなる。そのため、[[どどんとふ公式鯖]]<ref>[https://twitter.com/DoDontoF_Srv/status/1112201807239901184 どどんとふ公式鯖とねこ卓公式鯖と氷丼公式鯖中の人さんのツイート: "2020年12月にどどんとふ公式鯖終了がかなり濃厚です。HTML5版を残すかは開発体制状況次第です。 Quoridornやねこ卓その他ツールは継続予定ですが、サーバー負荷は激減するけど収益も激減するのは確実なので、そこら辺をどうするかも課題です。無罪になったのにCoinhive無くなっちゃうしなあ。"]</ref>や[[どどんとふむせる]]<ref>[http://museru.blog.jp/archives/1066846255.html どどんとふ「むせる」の終了時期について : むせるいんふぉめーしょん]</ref>では、管理者が2020年にどどんとふの提供を終了することを宣言している。 なお、[[Ruby]]で書かれているどどんとふのサーバープログラムは、Flash廃止の影響を受けず、2021年以降も動作する。そのため、クライアントプログラムのみ[[HTML5]]で書き直す試みが行われている(kitt氏の[[HTML5版どどんとふ]])。HTML5版のクライアントが十分に動作するようになれば、2021年以降もどどんとふを使ってオンラインセッションを楽しむことができる可能性はある。 == 設置 == === 小規模サーバー === 以下の説明は公式マニュアル<ref>[http://www.melonbooks.com/index.php?main_page=product_info&products_id=IT0000197863 どどんとふで始める初めてのオンラインセッション2017年夏の号!]</ref>を基にしている。 少人数で使用する場合は、[[Ruby]](1.8.7以上)が使えるレンタルサーバーにファイルを置き、パーミッションの設定をするだけでよい。マニュアルでは、さくらインターネットのレンタルサーバー([https://www.sakura.ne.jp/ さくらのレンタルサーバ])が推奨されている。 まず、公式サイトの[http://www.dodontof.com/index.php?option=com_content&view=article&id=246&Itemid=126 ダウンロードページ]から最新版または安定版のzipファイルをダウンロードし、展開する。さくらのレンタルサーバでアカウント名が「trpg_net」の場合、展開したファイルを以下のように配置し、パーミッションを設定する。 <pre> home +- trpg_net +- www | +- DodontoF (705) | | +- DodontoFServer.rb (705) | | +- log.txt (600) | | +- log.txt.0 (600) | | +- saveDataTempSpace (705) | | +- fileUploadSpace (705) | | +- replayDataUploadSpace (705) | +- imageUploadSpace (705) | +- smallImages (705) +- saveData (705) </pre> ファイルの配置およびパーミッション設定が完了したら、ブラウザから <code>DodontoF/DodontoFServer.rb</code> を開く。上記の例の場合、URLは <pre>http://trpg_net.sakura.ne.jp/DodontoF/DodontoFServer.rb</pre> となる。ファイルの配置およびパーミッション設定が正しくできていれば、以下のように表示される。 <syntaxhighlight lang="json"> ["「どどんとふ」の動作環境は正常に起動しています。"] </syntaxhighlight> 上記のメッセージが表示されたら、<code>DodontoF/DodontoF.swf</code> を開く。上記の例の場合、URLは <pre>http://trpg_net.sakura.ne.jp/DodontoF/DodontoF.swf</pre> となる。 === 大規模サーバー === レンタルサーバーを使う場合、快適に使用できる人数は10人程度までであり、それ以上の人数では負荷が重くなる。大規模なサーバーでは、以下のような構成とする例が多い。 * より高性能なサーバーやVPSを使う。 ** SSDを使う。 ** メモリに余裕があれば、RAMディスクを使う。 ** 必要に応じて、TCP/IPに関するLinuxカーネルのチューニングを行う。 * Webサーバーとしてnginxを使う。 * 最新のRubyを使う。 * FastCGIを使う。 ** spawn-fcgiなどでサーバープログラムを起動する。 ** Gem「fcgi」を使う。 * Gem「msgpack」を使う。 * 擬似cometモードを使わない。 設置の手順を解説している記事として、以下のものがある。 * [http://cre.jp/techblog/2016/01/27/dodontof-centos7-nginx-spawn/ クリエイターズネットワーク技術部ブログ » CentOS7+nginx+spawn-fcgi でどどんとふを動かす] ** [[TRPG.NET]]へのどどんとふの設置時の作業を基にしている。 * 大ちゃんのいろいろ雑記 - どどんとふをdebian+nginxで動かすやり方(nginxセットアップ編)@公式鯖3rdシリーズ ** [[どどんとふ公式鯖]]へのどどんとふ設置作業の記録。ハードウェアの性能を満たすのは難しいが、各要素は参考になる。 *# [https://www.taruki.com/wp/?p=6099 OS編] *# [https://www.taruki.com/wp/?p=6123 nginxセットアップ編] *# [https://www.taruki.com/wp/?p=6133 fcgi編] *# [https://www.taruki.com/wp/?p=6160 どどんとふ本体編] *# [https://www.taruki.com/wp/?p=6162 運用ツール編(最低限)] *# [https://www.taruki.com/wp/?p=6165 運用ツール編(その他)] *# [https://www.taruki.com/wp/?p=6182 運用ツール編(負荷グラフ)] == 脚注 == <references /> [[Category:TRPGツール]] {{DEFAULTSORT:ととんとふ}} d1b88d7dc348b54cc59c831a8193ebd4d2d4fd27 ファイル:dodontof-screenshot.png 6 11 17 2019-06-23T12:58:51Z Ochaochaocha3 1 どどんとふのスクリーンショット。 wikitext text/x-wiki == 概要 == どどんとふのスクリーンショット。 107cf9ce4dc4808aebd04a73bac3197baae9a1ad IRC 0 14 29 2019-06-23T15:18:51Z Ochaochaocha3 1 ページの作成:「'''IRC'''(Internet Relay Chat)は、チャットプロトコルのひとつ。1990年代からTRPGのオンラインセッションに利用されている。 == 概…」 wikitext text/x-wiki '''IRC'''(Internet Relay Chat)は、チャットプロトコルのひとつ。1990年代からTRPGのオンラインセッションに利用されている。 == 概要 == 古くからある高速、軽快なチャットプロトコル。1988年にフィンランドのプログラマJarkko Oikarinenによって開発された<ref>[http://www.irc.org/history_docs/jarkko.html IRC History by Jarkko Oikarinen - IRC.org]</ref>。[[Skype]]や[[Discord]]などが普及する以前は、チャットにおける事実上の標準プロトコルだった<ref>[http://hiki.trpg.net/wiki/?IRC 旧TRPG.NET Wiki - IRC]</ref>。 IRCによるチャットを行うには、クライアントソフトウェア(クライアント)と呼ばれる専用のプログラムを使う。用意されたサーバへクライアントを使用して接続することで、多くのユーザがほぼリアルタイムの会話を行える。IRCはあくまでプロトコルであるため、クライアントが対応していれば、PCやタブレット端末、スマートフォンといった様々な種類の端末からチャットに参加できる。また、クライアントには多くの種類があり、ユーザが好みのものを使うことができる。 == TRPGのオンラインセッションにおけるIRCの利用 == 2000年代前半まではチャットにおける事実上の標準プロトコルだったため、TRPGのオンラインセッションにIRCがよく利用されていた。より高機能なチャットプラットフォームが普及した現在も廃れてはおらず、一定数の利用者がいる。基本的には文章のみでセッションを進めることになるが、アップロードした画像のURLを送信する、[[ダイスボット]]というダイスロールを模倣するプログラムを利用するなどの方法により、より多くの情報を導入することができる。 日本では、1990年代後半に[[TRPG.NET]]がIRCネットワークirc.trpg.net系の運用を開始し、オンラインセッションに多く利用されてきた。現在は[[irc.cre.jp系]]として運用されている。 == 規格 == 1993年に[https://tools.ietf.org/html/rfc1459 RFC 1459]([http://web.archive.org/web/20111228003516/http://www.haun.org/kent/lib/rfc1459-irc-ja.html 日本語訳のアーカイブ])が公表され、このRFCに準拠するようにサーバソフトウェアやクライアントソフトウェアが実装されてきた。 2000年には、以下の4つのRFCが発表された。 * [https://tools.ietf.org/html/rfc2810 RFC 2810]([http://web.archive.org/web/20070705011756/http://www.alt-r.com/lib/rfc2810j.html 日本語訳のアーカイブ]):アーキテクチャ * [https://tools.ietf.org/html/rfc2811 RFC 2811]([http://web.archive.org/web/20070403224951/http://www.alt-r.com/lib/rfc2811j.html 日本語訳のアーカイブ]):チャンネル管理 * [https://tools.ietf.org/html/rfc2812 RFC 2812]([http://web.archive.org/web/20070701072918/http://www.alt-r.com/lib/rfc2812j.html 日本語訳のアーカイブ]):クライアントプロトコル * [https://tools.ietf.org/html/rfc2813 RFC 2813]([http://web.archive.org/web/20070617180733/http://www.alt-r.com/lib/rfc2813j.html 日本語訳のアーカイブ]):サーバプロトコル 2014年には、TLS/SSLを利用してIRCの通信を暗号化する「ircs-u」について説明する[https://tools.ietf.org/html/rfc7194 RFC 7194]が発表された。 == 脚注 == <references /> 0cb69b95f83547295b80fb07071dda068c3b9691 IRC 0 14 30 29 2019-06-23T15:23:06Z Ochaochaocha3 1 /* 規格 */ 読点を加える wikitext text/x-wiki '''IRC'''(Internet Relay Chat)は、チャットプロトコルのひとつ。1990年代からTRPGのオンラインセッションに利用されている。 == 概要 == 古くからある高速、軽快なチャットプロトコル。1988年にフィンランドのプログラマJarkko Oikarinenによって開発された<ref>[http://www.irc.org/history_docs/jarkko.html IRC History by Jarkko Oikarinen - IRC.org]</ref>。[[Skype]]や[[Discord]]などが普及する以前は、チャットにおける事実上の標準プロトコルだった<ref>[http://hiki.trpg.net/wiki/?IRC 旧TRPG.NET Wiki - IRC]</ref>。 IRCによるチャットを行うには、クライアントソフトウェア(クライアント)と呼ばれる専用のプログラムを使う。用意されたサーバへクライアントを使用して接続することで、多くのユーザがほぼリアルタイムの会話を行える。IRCはあくまでプロトコルであるため、クライアントが対応していれば、PCやタブレット端末、スマートフォンといった様々な種類の端末からチャットに参加できる。また、クライアントには多くの種類があり、ユーザが好みのものを使うことができる。 == TRPGのオンラインセッションにおけるIRCの利用 == 2000年代前半まではチャットにおける事実上の標準プロトコルだったため、TRPGのオンラインセッションにIRCがよく利用されていた。より高機能なチャットプラットフォームが普及した現在も廃れてはおらず、一定数の利用者がいる。基本的には文章のみでセッションを進めることになるが、アップロードした画像のURLを送信する、[[ダイスボット]]というダイスロールを模倣するプログラムを利用するなどの方法により、より多くの情報を導入することができる。 日本では、1990年代後半に[[TRPG.NET]]がIRCネットワークirc.trpg.net系の運用を開始し、オンラインセッションに多く利用されてきた。現在は[[irc.cre.jp系]]として運用されている。 == 規格 == 1993年に[https://tools.ietf.org/html/rfc1459 RFC 1459]([http://web.archive.org/web/20111228003516/http://www.haun.org/kent/lib/rfc1459-irc-ja.html 日本語訳のアーカイブ])が公表され、このRFCに準拠するようにサーバソフトウェアやクライアントソフトウェアが実装されてきた。 2000年には、以下の4つのRFCが発表された。 * [https://tools.ietf.org/html/rfc2810 RFC 2810]([http://web.archive.org/web/20070705011756/http://www.alt-r.com/lib/rfc2810j.html 日本語訳のアーカイブ]):アーキテクチャ * [https://tools.ietf.org/html/rfc2811 RFC 2811]([http://web.archive.org/web/20070403224951/http://www.alt-r.com/lib/rfc2811j.html 日本語訳のアーカイブ]):チャンネル管理 * [https://tools.ietf.org/html/rfc2812 RFC 2812]([http://web.archive.org/web/20070701072918/http://www.alt-r.com/lib/rfc2812j.html 日本語訳のアーカイブ]):クライアントプロトコル * [https://tools.ietf.org/html/rfc2813 RFC 2813]([http://web.archive.org/web/20070617180733/http://www.alt-r.com/lib/rfc2813j.html 日本語訳のアーカイブ]):サーバプロトコル 2014年には、TLS/SSLを利用してIRCの通信を暗号化する「ircs-u」について説明する、[https://tools.ietf.org/html/rfc7194 RFC 7194]が発表された。 == 脚注 == <references /> c7e361690798c017ff4a702aca3cd8370f7358fb 32 30 2019-06-23T15:26:33Z Ochaochaocha3 1 カテゴリを追加する wikitext text/x-wiki '''IRC'''(Internet Relay Chat)は、チャットプロトコルのひとつ。1990年代からTRPGのオンラインセッションに利用されている。 == 概要 == 古くからある高速、軽快なチャットプロトコル。1988年にフィンランドのプログラマJarkko Oikarinenによって開発された<ref>[http://www.irc.org/history_docs/jarkko.html IRC History by Jarkko Oikarinen - IRC.org]</ref>。[[Skype]]や[[Discord]]などが普及する以前は、チャットにおける事実上の標準プロトコルだった<ref>[http://hiki.trpg.net/wiki/?IRC 旧TRPG.NET Wiki - IRC]</ref>。 IRCによるチャットを行うには、クライアントソフトウェア(クライアント)と呼ばれる専用のプログラムを使う。用意されたサーバへクライアントを使用して接続することで、多くのユーザがほぼリアルタイムの会話を行える。IRCはあくまでプロトコルであるため、クライアントが対応していれば、PCやタブレット端末、スマートフォンといった様々な種類の端末からチャットに参加できる。また、クライアントには多くの種類があり、ユーザが好みのものを使うことができる。 == TRPGのオンラインセッションにおけるIRCの利用 == 2000年代前半まではチャットにおける事実上の標準プロトコルだったため、TRPGのオンラインセッションにIRCがよく利用されていた。より高機能なチャットプラットフォームが普及した現在も廃れてはおらず、一定数の利用者がいる。基本的には文章のみでセッションを進めることになるが、アップロードした画像のURLを送信する、[[ダイスボット]]というダイスロールを模倣するプログラムを利用するなどの方法により、より多くの情報を導入することができる。 日本では、1990年代後半に[[TRPG.NET]]がIRCネットワークirc.trpg.net系の運用を開始し、オンラインセッションに多く利用されてきた。現在は[[irc.cre.jp系]]として運用されている。 == 規格 == 1993年に[https://tools.ietf.org/html/rfc1459 RFC 1459]([http://web.archive.org/web/20111228003516/http://www.haun.org/kent/lib/rfc1459-irc-ja.html 日本語訳のアーカイブ])が公表され、このRFCに準拠するようにサーバソフトウェアやクライアントソフトウェアが実装されてきた。 2000年には、以下の4つのRFCが発表された。 * [https://tools.ietf.org/html/rfc2810 RFC 2810]([http://web.archive.org/web/20070705011756/http://www.alt-r.com/lib/rfc2810j.html 日本語訳のアーカイブ]):アーキテクチャ * [https://tools.ietf.org/html/rfc2811 RFC 2811]([http://web.archive.org/web/20070403224951/http://www.alt-r.com/lib/rfc2811j.html 日本語訳のアーカイブ]):チャンネル管理 * [https://tools.ietf.org/html/rfc2812 RFC 2812]([http://web.archive.org/web/20070701072918/http://www.alt-r.com/lib/rfc2812j.html 日本語訳のアーカイブ]):クライアントプロトコル * [https://tools.ietf.org/html/rfc2813 RFC 2813]([http://web.archive.org/web/20070617180733/http://www.alt-r.com/lib/rfc2813j.html 日本語訳のアーカイブ]):サーバプロトコル 2014年には、TLS/SSLを利用してIRCの通信を暗号化する「ircs-u」について説明する、[https://tools.ietf.org/html/rfc7194 RFC 7194]が発表された。 == 脚注 == <references /> [[Category:チャット]] 9b811959ebead55f9a9643b3dbde54d33bd88ef2 49 32 2019-06-23T16:58:58Z Ochaochaocha3 1 /* 規格 */ wikitext text/x-wiki '''IRC'''(Internet Relay Chat)は、チャットプロトコルのひとつ。1990年代からTRPGのオンラインセッションに利用されている。 == 概要 == 古くからある高速、軽快なチャットプロトコル。1988年にフィンランドのプログラマJarkko Oikarinenによって開発された<ref>[http://www.irc.org/history_docs/jarkko.html IRC History by Jarkko Oikarinen - IRC.org]</ref>。[[Skype]]や[[Discord]]などが普及する以前は、チャットにおける事実上の標準プロトコルだった<ref>[http://hiki.trpg.net/wiki/?IRC 旧TRPG.NET Wiki - IRC]</ref>。 IRCによるチャットを行うには、クライアントソフトウェア(クライアント)と呼ばれる専用のプログラムを使う。用意されたサーバへクライアントを使用して接続することで、多くのユーザがほぼリアルタイムの会話を行える。IRCはあくまでプロトコルであるため、クライアントが対応していれば、PCやタブレット端末、スマートフォンといった様々な種類の端末からチャットに参加できる。また、クライアントには多くの種類があり、ユーザが好みのものを使うことができる。 == TRPGのオンラインセッションにおけるIRCの利用 == 2000年代前半まではチャットにおける事実上の標準プロトコルだったため、TRPGのオンラインセッションにIRCがよく利用されていた。より高機能なチャットプラットフォームが普及した現在も廃れてはおらず、一定数の利用者がいる。基本的には文章のみでセッションを進めることになるが、アップロードした画像のURLを送信する、[[ダイスボット]]というダイスロールを模倣するプログラムを利用するなどの方法により、より多くの情報を導入することができる。 日本では、1990年代後半に[[TRPG.NET]]がIRCネットワークirc.trpg.net系の運用を開始し、オンラインセッションに多く利用されてきた。現在は[[irc.cre.jp系]]として運用されている。 == 規格 == 1993年に、Jarkko Oikarinenが[https://tools.ietf.org/html/rfc1459 RFC 1459]([http://web.archive.org/web/20111228003516/http://www.haun.org/kent/lib/rfc1459-irc-ja.html 日本語訳のアーカイブ])を発表した。このRFCに準拠するように、サーバソフトウェアやクライアントソフトウェアが実装されてきた。 2000年には、Christophe Kaltが以下の4つのRFCを発表した。 * [https://tools.ietf.org/html/rfc2810 RFC 2810]([http://web.archive.org/web/20070705011756/http://www.alt-r.com/lib/rfc2810j.html 日本語訳のアーカイブ]):アーキテクチャ * [https://tools.ietf.org/html/rfc2811 RFC 2811]([http://web.archive.org/web/20070403224951/http://www.alt-r.com/lib/rfc2811j.html 日本語訳のアーカイブ]):チャンネル管理 * [https://tools.ietf.org/html/rfc2812 RFC 2812]([http://web.archive.org/web/20070701072918/http://www.alt-r.com/lib/rfc2812j.html 日本語訳のアーカイブ]):クライアントプロトコル * [https://tools.ietf.org/html/rfc2813 RFC 2813]([http://web.archive.org/web/20070617180733/http://www.alt-r.com/lib/rfc2813j.html 日本語訳のアーカイブ]):サーバプロトコル 2014年には、Richard Hartmannが[https://tools.ietf.org/html/rfc7194 RFC 7194]を発表した。このRFCでは、TLS/SSLを利用してIRCの通信を暗号化する「ircs-u」の内容が述べられている。 == 脚注 == <references /> [[Category:チャット]] a9490c997bfdcfe3ef1ad8ba36f5c913fcdf4de3 どどんとふ 0 10 31 28 2019-06-23T15:24:16Z Ochaochaocha3 1 開発された→開発されている wikitext text/x-wiki [[ファイル:dodontof-screenshot.png|サムネイル|どどんとふのスクリーンショット]] '''どどんとふ'''は、たいたい竹流氏によって開発されているオンラインセッションツール。 * 公式サイト:[http://www.dodontof.com/ どどんとふ@えくすとり~む] * 公式マニュアル:[http://www.melonbooks.com/index.php?main_page=product_info&products_id=IT0000197863 どどんとふで始める初めてのオンラインセッション2017年夏の号!] * GitHubリポジトリ:[https://github.com/torgtaitai/DodontoF torgtaitai/DodontoF] * 使用技術:[[Flash]]、[[Ruby]] == 概要 == <blockquote> 「どどんとふ」はTRPGのオンラインセッションをお手軽&楽しく遊ぶために作られたツールです。<br /> ブラウザだけで全ての操作が可能。<br /> マップ表示もキャラクター配置もチャットもイニシアティブ管理も、さらには動画や音楽の共有まで楽しめます。<br /> OSをほとんど気にせず動作します。WindowsでもMacでもUNIXでもOK。<br /> 「<cite>[http://www.dodontof.com/DodontoF/README.html 「どどんとふ」マニュアル]</cite>」より引用 </blockquote> オンラインセッションに必要な多くの機能を備えた、総合オンラインセッションツール。部屋の作成、チャット、ダイスボット、キャラクター管理、マップ管理、イニシアティブ表といった基本的な機能に加えて、以下のような豊富な機能を搭載している。 * 秘話チャット * シークレットダイス * ダイスシンボル * 共有メモ * カード * 資源管理 * 範囲 * 魔法タイマー * チット設置 * マップ手書き * 画像のアップロード * Webカメラ撮影 * 立ち絵 * ノベルゲーム風表示 * カットイン * 読み上げ * リプレイ録画 * 多言語対応 === ダイスボット === ダイスボットとして[[BCDice]](ボーンズ&カーズ)を使用している。現在のBCDiceは、どどんとふ環境で動作することを前提として開発、テストされている。様々なゲームシステムのダイスロールおよび表引きに加え、独自の表の追加、カード機能などBCDiceの機能をフル活用しているのは、どどんとふならではである。 == Flashの廃止に伴う影響 == どどんとふのクライアントプログラム(プレイヤーが操作する画面のプログラム)は、[[Flash]]を使用して作られている。Flashは2020年に廃止されることが決定しており、2021年以降、通常はブラウザからクライアントプログラムを動作させることができなくなる。そのため、[[どどんとふ公式鯖]]<ref>[https://twitter.com/DoDontoF_Srv/status/1112201807239901184 どどんとふ公式鯖とねこ卓公式鯖と氷丼公式鯖中の人さんのツイート: "2020年12月にどどんとふ公式鯖終了がかなり濃厚です。HTML5版を残すかは開発体制状況次第です。 Quoridornやねこ卓その他ツールは継続予定ですが、サーバー負荷は激減するけど収益も激減するのは確実なので、そこら辺をどうするかも課題です。無罪になったのにCoinhive無くなっちゃうしなあ。"]</ref>や[[どどんとふむせる]]<ref>[http://museru.blog.jp/archives/1066846255.html どどんとふ「むせる」の終了時期について : むせるいんふぉめーしょん]</ref>では、管理者が2020年にどどんとふの提供を終了することを宣言している。 なお、[[Ruby]]で書かれているどどんとふのサーバープログラムは、Flash廃止の影響を受けず、2021年以降も動作する。そのため、クライアントプログラムのみ[[HTML5]]で書き直す試みが行われている(kitt氏の[[HTML5版どどんとふ]])。HTML5版のクライアントが十分に動作するようになれば、2021年以降もどどんとふを使ってオンラインセッションを楽しむことができる可能性はある。 == 設置 == === 小規模サーバー === 以下の説明は公式マニュアル<ref>[http://www.melonbooks.com/index.php?main_page=product_info&products_id=IT0000197863 どどんとふで始める初めてのオンラインセッション2017年夏の号!]</ref>を基にしている。 少人数で使用する場合は、[[Ruby]](1.8.7以上)が使えるレンタルサーバーにファイルを置き、パーミッションの設定をするだけでよい。マニュアルでは、さくらインターネットのレンタルサーバー([https://www.sakura.ne.jp/ さくらのレンタルサーバ])が推奨されている。 まず、公式サイトの[http://www.dodontof.com/index.php?option=com_content&view=article&id=246&Itemid=126 ダウンロードページ]から最新版または安定版のzipファイルをダウンロードし、展開する。さくらのレンタルサーバでアカウント名が「trpg_net」の場合、展開したファイルを以下のように配置し、パーミッションを設定する。 <pre> home +- trpg_net +- www | +- DodontoF (705) | | +- DodontoFServer.rb (705) | | +- log.txt (600) | | +- log.txt.0 (600) | | +- saveDataTempSpace (705) | | +- fileUploadSpace (705) | | +- replayDataUploadSpace (705) | +- imageUploadSpace (705) | +- smallImages (705) +- saveData (705) </pre> ファイルの配置およびパーミッション設定が完了したら、ブラウザから <code>DodontoF/DodontoFServer.rb</code> を開く。上記の例の場合、URLは <pre>http://trpg_net.sakura.ne.jp/DodontoF/DodontoFServer.rb</pre> となる。ファイルの配置およびパーミッション設定が正しくできていれば、以下のように表示される。 <syntaxhighlight lang="json"> ["「どどんとふ」の動作環境は正常に起動しています。"] </syntaxhighlight> 上記のメッセージが表示されたら、<code>DodontoF/DodontoF.swf</code> を開く。上記の例の場合、URLは <pre>http://trpg_net.sakura.ne.jp/DodontoF/DodontoF.swf</pre> となる。 === 大規模サーバー === レンタルサーバーを使う場合、快適に使用できる人数は10人程度までであり、それ以上の人数では負荷が重くなる。大規模なサーバーでは、以下のような構成とする例が多い。 * より高性能なサーバーやVPSを使う。 ** SSDを使う。 ** メモリに余裕があれば、RAMディスクを使う。 ** 必要に応じて、TCP/IPに関するLinuxカーネルのチューニングを行う。 * Webサーバーとしてnginxを使う。 * 最新のRubyを使う。 * FastCGIを使う。 ** spawn-fcgiなどでサーバープログラムを起動する。 ** Gem「fcgi」を使う。 * Gem「msgpack」を使う。 * 擬似cometモードを使わない。 設置の手順を解説している記事として、以下のものがある。 * [http://cre.jp/techblog/2016/01/27/dodontof-centos7-nginx-spawn/ クリエイターズネットワーク技術部ブログ » CentOS7+nginx+spawn-fcgi でどどんとふを動かす] ** [[TRPG.NET]]へのどどんとふの設置時の作業を基にしている。 * 大ちゃんのいろいろ雑記 - どどんとふをdebian+nginxで動かすやり方(nginxセットアップ編)@公式鯖3rdシリーズ ** [[どどんとふ公式鯖]]へのどどんとふ設置作業の記録。ハードウェアの性能を満たすのは難しいが、各要素は参考になる。 *# [https://www.taruki.com/wp/?p=6099 OS編] *# [https://www.taruki.com/wp/?p=6123 nginxセットアップ編] *# [https://www.taruki.com/wp/?p=6133 fcgi編] *# [https://www.taruki.com/wp/?p=6160 どどんとふ本体編] *# [https://www.taruki.com/wp/?p=6162 運用ツール編(最低限)] *# [https://www.taruki.com/wp/?p=6165 運用ツール編(その他)] *# [https://www.taruki.com/wp/?p=6182 運用ツール編(負荷グラフ)] == 脚注 == <references /> [[Category:TRPGツール]] {{DEFAULTSORT:ととんとふ}} a7a8b11e7bfe492b5401c5e91fa0402ff62af671 33 31 2019-06-23T15:28:44Z Ochaochaocha3 1 たいたい竹流氏のTwitterアカウントへのリンクを追加する wikitext text/x-wiki [[ファイル:dodontof-screenshot.png|サムネイル|どどんとふのスクリーンショット]] '''どどんとふ'''は、[https://twitter.com/torgtaitai たいたい竹流氏]によって開発されているオンラインセッションツール。 * 公式サイト:[http://www.dodontof.com/ どどんとふ@えくすとり~む] * 公式マニュアル:[http://www.melonbooks.com/index.php?main_page=product_info&products_id=IT0000197863 どどんとふで始める初めてのオンラインセッション2017年夏の号!] * GitHubリポジトリ:[https://github.com/torgtaitai/DodontoF torgtaitai/DodontoF] * 使用技術:[[Flash]]、[[Ruby]] == 概要 == <blockquote> 「どどんとふ」はTRPGのオンラインセッションをお手軽&楽しく遊ぶために作られたツールです。<br /> ブラウザだけで全ての操作が可能。<br /> マップ表示もキャラクター配置もチャットもイニシアティブ管理も、さらには動画や音楽の共有まで楽しめます。<br /> OSをほとんど気にせず動作します。WindowsでもMacでもUNIXでもOK。<br /> 「<cite>[http://www.dodontof.com/DodontoF/README.html 「どどんとふ」マニュアル]</cite>」より引用 </blockquote> オンラインセッションに必要な多くの機能を備えた、総合オンラインセッションツール。部屋の作成、チャット、ダイスボット、キャラクター管理、マップ管理、イニシアティブ表といった基本的な機能に加えて、以下のような豊富な機能を搭載している。 * 秘話チャット * シークレットダイス * ダイスシンボル * 共有メモ * カード * 資源管理 * 範囲 * 魔法タイマー * チット設置 * マップ手書き * 画像のアップロード * Webカメラ撮影 * 立ち絵 * ノベルゲーム風表示 * カットイン * 読み上げ * リプレイ録画 * 多言語対応 === ダイスボット === ダイスボットとして[[BCDice]](ボーンズ&カーズ)を使用している。現在のBCDiceは、どどんとふ環境で動作することを前提として開発、テストされている。様々なゲームシステムのダイスロールおよび表引きに加え、独自の表の追加、カード機能などBCDiceの機能をフル活用しているのは、どどんとふならではである。 == Flashの廃止に伴う影響 == どどんとふのクライアントプログラム(プレイヤーが操作する画面のプログラム)は、[[Flash]]を使用して作られている。Flashは2020年に廃止されることが決定しており、2021年以降、通常はブラウザからクライアントプログラムを動作させることができなくなる。そのため、[[どどんとふ公式鯖]]<ref>[https://twitter.com/DoDontoF_Srv/status/1112201807239901184 どどんとふ公式鯖とねこ卓公式鯖と氷丼公式鯖中の人さんのツイート: "2020年12月にどどんとふ公式鯖終了がかなり濃厚です。HTML5版を残すかは開発体制状況次第です。 Quoridornやねこ卓その他ツールは継続予定ですが、サーバー負荷は激減するけど収益も激減するのは確実なので、そこら辺をどうするかも課題です。無罪になったのにCoinhive無くなっちゃうしなあ。"]</ref>や[[どどんとふむせる]]<ref>[http://museru.blog.jp/archives/1066846255.html どどんとふ「むせる」の終了時期について : むせるいんふぉめーしょん]</ref>では、管理者が2020年にどどんとふの提供を終了することを宣言している。 なお、[[Ruby]]で書かれているどどんとふのサーバープログラムは、Flash廃止の影響を受けず、2021年以降も動作する。そのため、クライアントプログラムのみ[[HTML5]]で書き直す試みが行われている(kitt氏の[[HTML5版どどんとふ]])。HTML5版のクライアントが十分に動作するようになれば、2021年以降もどどんとふを使ってオンラインセッションを楽しむことができる可能性はある。 == 設置 == === 小規模サーバー === 以下の説明は公式マニュアル<ref>[http://www.melonbooks.com/index.php?main_page=product_info&products_id=IT0000197863 どどんとふで始める初めてのオンラインセッション2017年夏の号!]</ref>を基にしている。 少人数で使用する場合は、[[Ruby]](1.8.7以上)が使えるレンタルサーバーにファイルを置き、パーミッションの設定をするだけでよい。マニュアルでは、さくらインターネットのレンタルサーバー([https://www.sakura.ne.jp/ さくらのレンタルサーバ])が推奨されている。 まず、公式サイトの[http://www.dodontof.com/index.php?option=com_content&view=article&id=246&Itemid=126 ダウンロードページ]から最新版または安定版のzipファイルをダウンロードし、展開する。さくらのレンタルサーバでアカウント名が「trpg_net」の場合、展開したファイルを以下のように配置し、パーミッションを設定する。 <pre> home +- trpg_net +- www | +- DodontoF (705) | | +- DodontoFServer.rb (705) | | +- log.txt (600) | | +- log.txt.0 (600) | | +- saveDataTempSpace (705) | | +- fileUploadSpace (705) | | +- replayDataUploadSpace (705) | +- imageUploadSpace (705) | +- smallImages (705) +- saveData (705) </pre> ファイルの配置およびパーミッション設定が完了したら、ブラウザから <code>DodontoF/DodontoFServer.rb</code> を開く。上記の例の場合、URLは <pre>http://trpg_net.sakura.ne.jp/DodontoF/DodontoFServer.rb</pre> となる。ファイルの配置およびパーミッション設定が正しくできていれば、以下のように表示される。 <syntaxhighlight lang="json"> ["「どどんとふ」の動作環境は正常に起動しています。"] </syntaxhighlight> 上記のメッセージが表示されたら、<code>DodontoF/DodontoF.swf</code> を開く。上記の例の場合、URLは <pre>http://trpg_net.sakura.ne.jp/DodontoF/DodontoF.swf</pre> となる。 === 大規模サーバー === レンタルサーバーを使う場合、快適に使用できる人数は10人程度までであり、それ以上の人数では負荷が重くなる。大規模なサーバーでは、以下のような構成とする例が多い。 * より高性能なサーバーやVPSを使う。 ** SSDを使う。 ** メモリに余裕があれば、RAMディスクを使う。 ** 必要に応じて、TCP/IPに関するLinuxカーネルのチューニングを行う。 * Webサーバーとしてnginxを使う。 * 最新のRubyを使う。 * FastCGIを使う。 ** spawn-fcgiなどでサーバープログラムを起動する。 ** Gem「fcgi」を使う。 * Gem「msgpack」を使う。 * 擬似cometモードを使わない。 設置の手順を解説している記事として、以下のものがある。 * [http://cre.jp/techblog/2016/01/27/dodontof-centos7-nginx-spawn/ クリエイターズネットワーク技術部ブログ » CentOS7+nginx+spawn-fcgi でどどんとふを動かす] ** [[TRPG.NET]]へのどどんとふの設置時の作業を基にしている。 * 大ちゃんのいろいろ雑記 - どどんとふをdebian+nginxで動かすやり方(nginxセットアップ編)@公式鯖3rdシリーズ ** [[どどんとふ公式鯖]]へのどどんとふ設置作業の記録。ハードウェアの性能を満たすのは難しいが、各要素は参考になる。 *# [https://www.taruki.com/wp/?p=6099 OS編] *# [https://www.taruki.com/wp/?p=6123 nginxセットアップ編] *# [https://www.taruki.com/wp/?p=6133 fcgi編] *# [https://www.taruki.com/wp/?p=6160 どどんとふ本体編] *# [https://www.taruki.com/wp/?p=6162 運用ツール編(最低限)] *# [https://www.taruki.com/wp/?p=6165 運用ツール編(その他)] *# [https://www.taruki.com/wp/?p=6182 運用ツール編(負荷グラフ)] == 脚注 == <references /> [[Category:TRPGツール]] {{DEFAULTSORT:ととんとふ}} 76160c1a59d063bdcf35fb3579dd623f2af4fe42 98 33 2019-06-23T17:30:22Z Ochaochaocha3 1 概要テンプレートを使用する wikitext text/x-wiki {{TRPGツール概要 | image = ファイル:dodontof-screenshot.png | キャプション = どどんとふのスクリーンショット | 開発者 = [https://twitter.com/torgtaitai たいたい竹流] | 公式サイト = [http://www.dodontof.com/ どどんとふ@えくすとり~む] | 公式マニュアル = [http://www.melonbooks.com/index.php?main_page=product_info&products_id=IT0000197863 どどんとふで始める初めてのオンラインセッション2017年夏の号!] | GitHubリポジトリ = [https://github.com/torgtaitai/DodontoF torgtaitai/DodontoF] | 使用技術 = [[Flash]]、[[Ruby]] }} == 概要 == <blockquote> 「どどんとふ」はTRPGのオンラインセッションをお手軽&楽しく遊ぶために作られたツールです。<br /> ブラウザだけで全ての操作が可能。<br /> マップ表示もキャラクター配置もチャットもイニシアティブ管理も、さらには動画や音楽の共有まで楽しめます。<br /> OSをほとんど気にせず動作します。WindowsでもMacでもUNIXでもOK。<br /> 「<cite>[http://www.dodontof.com/DodontoF/README.html 「どどんとふ」マニュアル]</cite>」より引用 </blockquote> オンラインセッションに必要な多くの機能を備えた、総合オンラインセッションツール。部屋の作成、チャット、ダイスボット、キャラクター管理、マップ管理、イニシアティブ表といった基本的な機能に加えて、以下のような豊富な機能を搭載している。 * 秘話チャット * シークレットダイス * ダイスシンボル * 共有メモ * カード * 資源管理 * 範囲 * 魔法タイマー * チット設置 * マップ手書き * 画像のアップロード * Webカメラ撮影 * 立ち絵 * ノベルゲーム風表示 * カットイン * 読み上げ * リプレイ録画 * 多言語対応 === ダイスボット === ダイスボットとして[[BCDice]](ボーンズ&カーズ)を使用している。現在のBCDiceは、どどんとふ環境で動作することを前提として開発、テストされている。様々なゲームシステムのダイスロールおよび表引きに加え、独自の表の追加、カード機能などBCDiceの機能をフル活用しているのは、どどんとふならではである。 == Flashの廃止に伴う影響 == どどんとふのクライアントプログラム(プレイヤーが操作する画面のプログラム)は、[[Flash]]を使用して作られている。Flashは2020年に廃止されることが決定しており、2021年以降、通常はブラウザからクライアントプログラムを動作させることができなくなる。そのため、[[どどんとふ公式鯖]]<ref>[https://twitter.com/DoDontoF_Srv/status/1112201807239901184 どどんとふ公式鯖とねこ卓公式鯖と氷丼公式鯖中の人さんのツイート: "2020年12月にどどんとふ公式鯖終了がかなり濃厚です。HTML5版を残すかは開発体制状況次第です。 Quoridornやねこ卓その他ツールは継続予定ですが、サーバー負荷は激減するけど収益も激減するのは確実なので、そこら辺をどうするかも課題です。無罪になったのにCoinhive無くなっちゃうしなあ。"]</ref>や[[どどんとふむせる]]<ref>[http://museru.blog.jp/archives/1066846255.html どどんとふ「むせる」の終了時期について : むせるいんふぉめーしょん]</ref>では、管理者が2020年にどどんとふの提供を終了することを宣言している。 なお、[[Ruby]]で書かれているどどんとふのサーバープログラムは、Flash廃止の影響を受けず、2021年以降も動作する。そのため、クライアントプログラムのみ[[HTML5]]で書き直す試みが行われている(kitt氏の[[HTML5版どどんとふ]])。HTML5版のクライアントが十分に動作するようになれば、2021年以降もどどんとふを使ってオンラインセッションを楽しむことができる可能性はある。 == 設置 == === 小規模サーバー === 以下の説明は公式マニュアル<ref>[http://www.melonbooks.com/index.php?main_page=product_info&products_id=IT0000197863 どどんとふで始める初めてのオンラインセッション2017年夏の号!]</ref>を基にしている。 少人数で使用する場合は、[[Ruby]](1.8.7以上)が使えるレンタルサーバーにファイルを置き、パーミッションの設定をするだけでよい。マニュアルでは、さくらインターネットのレンタルサーバー([https://www.sakura.ne.jp/ さくらのレンタルサーバ])が推奨されている。 まず、公式サイトの[http://www.dodontof.com/index.php?option=com_content&view=article&id=246&Itemid=126 ダウンロードページ]から最新版または安定版のzipファイルをダウンロードし、展開する。さくらのレンタルサーバでアカウント名が「trpg_net」の場合、展開したファイルを以下のように配置し、パーミッションを設定する。 <pre> home +- trpg_net +- www | +- DodontoF (705) | | +- DodontoFServer.rb (705) | | +- log.txt (600) | | +- log.txt.0 (600) | | +- saveDataTempSpace (705) | | +- fileUploadSpace (705) | | +- replayDataUploadSpace (705) | +- imageUploadSpace (705) | +- smallImages (705) +- saveData (705) </pre> ファイルの配置およびパーミッション設定が完了したら、ブラウザから <code>DodontoF/DodontoFServer.rb</code> を開く。上記の例の場合、URLは <pre>http://trpg_net.sakura.ne.jp/DodontoF/DodontoFServer.rb</pre> となる。ファイルの配置およびパーミッション設定が正しくできていれば、以下のように表示される。 <syntaxhighlight lang="json"> ["「どどんとふ」の動作環境は正常に起動しています。"] </syntaxhighlight> 上記のメッセージが表示されたら、<code>DodontoF/DodontoF.swf</code> を開く。上記の例の場合、URLは <pre>http://trpg_net.sakura.ne.jp/DodontoF/DodontoF.swf</pre> となる。 === 大規模サーバー === レンタルサーバーを使う場合、快適に使用できる人数は10人程度までであり、それ以上の人数では負荷が重くなる。大規模なサーバーでは、以下のような構成とする例が多い。 * より高性能なサーバーやVPSを使う。 ** SSDを使う。 ** メモリに余裕があれば、RAMディスクを使う。 ** 必要に応じて、TCP/IPに関するLinuxカーネルのチューニングを行う。 * Webサーバーとしてnginxを使う。 * 最新のRubyを使う。 * FastCGIを使う。 ** spawn-fcgiなどでサーバープログラムを起動する。 ** Gem「fcgi」を使う。 * Gem「msgpack」を使う。 * 擬似cometモードを使わない。 設置の手順を解説している記事として、以下のものがある。 * [http://cre.jp/techblog/2016/01/27/dodontof-centos7-nginx-spawn/ クリエイターズネットワーク技術部ブログ » CentOS7+nginx+spawn-fcgi でどどんとふを動かす] ** [[TRPG.NET]]へのどどんとふの設置時の作業を基にしている。 * 大ちゃんのいろいろ雑記 - どどんとふをdebian+nginxで動かすやり方(nginxセットアップ編)@公式鯖3rdシリーズ ** [[どどんとふ公式鯖]]へのどどんとふ設置作業の記録。ハードウェアの性能を満たすのは難しいが、各要素は参考になる。 *# [https://www.taruki.com/wp/?p=6099 OS編] *# [https://www.taruki.com/wp/?p=6123 nginxセットアップ編] *# [https://www.taruki.com/wp/?p=6133 fcgi編] *# [https://www.taruki.com/wp/?p=6160 どどんとふ本体編] *# [https://www.taruki.com/wp/?p=6162 運用ツール編(最低限)] *# [https://www.taruki.com/wp/?p=6165 運用ツール編(その他)] *# [https://www.taruki.com/wp/?p=6182 運用ツール編(負荷グラフ)] == 脚注 == <references /> [[Category:TRPGツール]] {{DEFAULTSORT:ととんとふ}} 7b0e2e3c2541ca8d16d92bf4dbfd0593e6c43e22 99 98 2019-06-23T17:41:22Z Ochaochaocha3 1 引用部分を除く(概要テンプレートと相性が悪いため) wikitext text/x-wiki {{TRPGツール概要 | image = ファイル:dodontof-screenshot.png | キャプション = どどんとふのスクリーンショット | 開発者 = [https://twitter.com/torgtaitai たいたい竹流] | 公式サイト = [http://www.dodontof.com/ どどんとふ@えくすとり~む] | 公式マニュアル = [http://www.melonbooks.com/index.php?main_page=product_info&products_id=IT0000197863 どどんとふで始める初めてのオンラインセッション2017年夏の号!] | GitHubリポジトリ = [https://github.com/torgtaitai/DodontoF torgtaitai/DodontoF] | 使用技術 = [[Flash]]、[[Ruby]] }} == 概要 == オンラインセッションに必要な多くの機能を備えた、総合オンラインセッションツール。部屋の作成、チャット、ダイスボット、キャラクター管理、マップ管理、イニシアティブ表といった基本的な機能に加えて、以下のような豊富な機能を搭載している。 * 秘話チャット * シークレットダイス * ダイスシンボル * 共有メモ * カード * 資源管理 * 範囲 * 魔法タイマー * チット設置 * マップ手書き * 画像のアップロード * Webカメラ撮影 * 立ち絵 * ノベルゲーム風表示 * カットイン * 読み上げ * リプレイ録画 * 多言語対応 === ダイスボット === ダイスボットとして[[BCDice]](ボーンズ&カーズ)を使用している。現在のBCDiceは、どどんとふ環境で動作することを前提として開発、テストされている。様々なゲームシステムのダイスロールおよび表引きに加え、独自の表の追加、カード機能などBCDiceの機能をフル活用しているのは、どどんとふならではである。 == Flashの廃止に伴う影響 == どどんとふのクライアントプログラム(プレイヤーが操作する画面のプログラム)は、[[Flash]]を使用して作られている。Flashは2020年に廃止されることが決定しており、2021年以降、通常はブラウザからクライアントプログラムを動作させることができなくなる。そのため、[[どどんとふ公式鯖]]<ref>[https://twitter.com/DoDontoF_Srv/status/1112201807239901184 どどんとふ公式鯖とねこ卓公式鯖と氷丼公式鯖中の人さんのツイート: "2020年12月にどどんとふ公式鯖終了がかなり濃厚です。HTML5版を残すかは開発体制状況次第です。 Quoridornやねこ卓その他ツールは継続予定ですが、サーバー負荷は激減するけど収益も激減するのは確実なので、そこら辺をどうするかも課題です。無罪になったのにCoinhive無くなっちゃうしなあ。"]</ref>や[[どどんとふむせる]]<ref>[http://museru.blog.jp/archives/1066846255.html どどんとふ「むせる」の終了時期について : むせるいんふぉめーしょん]</ref>では、管理者が2020年にどどんとふの提供を終了することを宣言している。 なお、[[Ruby]]で書かれているどどんとふのサーバープログラムは、Flash廃止の影響を受けず、2021年以降も動作する。そのため、クライアントプログラムのみ[[HTML5]]で書き直す試みが行われている(kitt氏の[[HTML5版どどんとふ]])。HTML5版のクライアントが十分に動作するようになれば、2021年以降もどどんとふを使ってオンラインセッションを楽しむことができる可能性はある。 == 設置 == === 小規模サーバー === 以下の説明は公式マニュアル<ref>[http://www.melonbooks.com/index.php?main_page=product_info&products_id=IT0000197863 どどんとふで始める初めてのオンラインセッション2017年夏の号!]</ref>を基にしている。 少人数で使用する場合は、[[Ruby]](1.8.7以上)が使えるレンタルサーバーにファイルを置き、パーミッションの設定をするだけでよい。マニュアルでは、さくらインターネットのレンタルサーバー([https://www.sakura.ne.jp/ さくらのレンタルサーバ])が推奨されている。 まず、公式サイトの[http://www.dodontof.com/index.php?option=com_content&view=article&id=246&Itemid=126 ダウンロードページ]から最新版または安定版のzipファイルをダウンロードし、展開する。さくらのレンタルサーバでアカウント名が「trpg_net」の場合、展開したファイルを以下のように配置し、パーミッションを設定する。 <pre> home +- trpg_net +- www | +- DodontoF (705) | | +- DodontoFServer.rb (705) | | +- log.txt (600) | | +- log.txt.0 (600) | | +- saveDataTempSpace (705) | | +- fileUploadSpace (705) | | +- replayDataUploadSpace (705) | +- imageUploadSpace (705) | +- smallImages (705) +- saveData (705) </pre> ファイルの配置およびパーミッション設定が完了したら、ブラウザから <code>DodontoF/DodontoFServer.rb</code> を開く。上記の例の場合、URLは <pre>http://trpg_net.sakura.ne.jp/DodontoF/DodontoFServer.rb</pre> となる。ファイルの配置およびパーミッション設定が正しくできていれば、以下のように表示される。 <syntaxhighlight lang="json"> ["「どどんとふ」の動作環境は正常に起動しています。"] </syntaxhighlight> 上記のメッセージが表示されたら、<code>DodontoF/DodontoF.swf</code> を開く。上記の例の場合、URLは <pre>http://trpg_net.sakura.ne.jp/DodontoF/DodontoF.swf</pre> となる。 === 大規模サーバー === レンタルサーバーを使う場合、快適に使用できる人数は10人程度までであり、それ以上の人数では負荷が重くなる。大規模なサーバーでは、以下のような構成とする例が多い。 * より高性能なサーバーやVPSを使う。 ** SSDを使う。 ** メモリに余裕があれば、RAMディスクを使う。 ** 必要に応じて、TCP/IPに関するLinuxカーネルのチューニングを行う。 * Webサーバーとしてnginxを使う。 * 最新のRubyを使う。 * FastCGIを使う。 ** spawn-fcgiなどでサーバープログラムを起動する。 ** Gem「fcgi」を使う。 * Gem「msgpack」を使う。 * 擬似cometモードを使わない。 設置の手順を解説している記事として、以下のものがある。 * [http://cre.jp/techblog/2016/01/27/dodontof-centos7-nginx-spawn/ クリエイターズネットワーク技術部ブログ » CentOS7+nginx+spawn-fcgi でどどんとふを動かす] ** [[TRPG.NET]]へのどどんとふの設置時の作業を基にしている。 * 大ちゃんのいろいろ雑記 - どどんとふをdebian+nginxで動かすやり方(nginxセットアップ編)@公式鯖3rdシリーズ ** [[どどんとふ公式鯖]]へのどどんとふ設置作業の記録。ハードウェアの性能を満たすのは難しいが、各要素は参考になる。 *# [https://www.taruki.com/wp/?p=6099 OS編] *# [https://www.taruki.com/wp/?p=6123 nginxセットアップ編] *# [https://www.taruki.com/wp/?p=6133 fcgi編] *# [https://www.taruki.com/wp/?p=6160 どどんとふ本体編] *# [https://www.taruki.com/wp/?p=6162 運用ツール編(最低限)] *# [https://www.taruki.com/wp/?p=6165 運用ツール編(その他)] *# [https://www.taruki.com/wp/?p=6182 運用ツール編(負荷グラフ)] == 脚注 == <references /> [[Category:TRPGツール]] {{DEFAULTSORT:ととんとふ}} d3f1b2725b40896dea75642c4aefd97b85096e31 100 99 2019-06-23T17:42:12Z Ochaochaocha3 1 リード文を元に戻す wikitext text/x-wiki {{TRPGツール概要 | image = ファイル:dodontof-screenshot.png | キャプション = どどんとふのスクリーンショット | 開発者 = [https://twitter.com/torgtaitai たいたい竹流] | 公式サイト = [http://www.dodontof.com/ どどんとふ@えくすとり~む] | 公式マニュアル = [http://www.melonbooks.com/index.php?main_page=product_info&products_id=IT0000197863 どどんとふで始める初めてのオンラインセッション2017年夏の号!] | GitHubリポジトリ = [https://github.com/torgtaitai/DodontoF torgtaitai/DodontoF] | 使用技術 = [[Flash]]、[[Ruby]] }} '''どどんとふ'''は、[https://twitter.com/torgtaitai たいたい竹流氏]によって開発されているオンラインセッションツール。 == 概要 == オンラインセッションに必要な多くの機能を備えた、総合オンラインセッションツール。部屋の作成、チャット、ダイスボット、キャラクター管理、マップ管理、イニシアティブ表といった基本的な機能に加えて、以下のような豊富な機能を搭載している。 * 秘話チャット * シークレットダイス * ダイスシンボル * 共有メモ * カード * 資源管理 * 範囲 * 魔法タイマー * チット設置 * マップ手書き * 画像のアップロード * Webカメラ撮影 * 立ち絵 * ノベルゲーム風表示 * カットイン * 読み上げ * リプレイ録画 * 多言語対応 === ダイスボット === ダイスボットとして[[BCDice]](ボーンズ&カーズ)を使用している。現在のBCDiceは、どどんとふ環境で動作することを前提として開発、テストされている。様々なゲームシステムのダイスロールおよび表引きに加え、独自の表の追加、カード機能などBCDiceの機能をフル活用しているのは、どどんとふならではである。 == Flashの廃止に伴う影響 == どどんとふのクライアントプログラム(プレイヤーが操作する画面のプログラム)は、[[Flash]]を使用して作られている。Flashは2020年に廃止されることが決定しており、2021年以降、通常はブラウザからクライアントプログラムを動作させることができなくなる。そのため、[[どどんとふ公式鯖]]<ref>[https://twitter.com/DoDontoF_Srv/status/1112201807239901184 どどんとふ公式鯖とねこ卓公式鯖と氷丼公式鯖中の人さんのツイート: "2020年12月にどどんとふ公式鯖終了がかなり濃厚です。HTML5版を残すかは開発体制状況次第です。 Quoridornやねこ卓その他ツールは継続予定ですが、サーバー負荷は激減するけど収益も激減するのは確実なので、そこら辺をどうするかも課題です。無罪になったのにCoinhive無くなっちゃうしなあ。"]</ref>や[[どどんとふむせる]]<ref>[http://museru.blog.jp/archives/1066846255.html どどんとふ「むせる」の終了時期について : むせるいんふぉめーしょん]</ref>では、管理者が2020年にどどんとふの提供を終了することを宣言している。 なお、[[Ruby]]で書かれているどどんとふのサーバープログラムは、Flash廃止の影響を受けず、2021年以降も動作する。そのため、クライアントプログラムのみ[[HTML5]]で書き直す試みが行われている(kitt氏の[[HTML5版どどんとふ]])。HTML5版のクライアントが十分に動作するようになれば、2021年以降もどどんとふを使ってオンラインセッションを楽しむことができる可能性はある。 == 設置 == === 小規模サーバー === 以下の説明は公式マニュアル<ref>[http://www.melonbooks.com/index.php?main_page=product_info&products_id=IT0000197863 どどんとふで始める初めてのオンラインセッション2017年夏の号!]</ref>を基にしている。 少人数で使用する場合は、[[Ruby]](1.8.7以上)が使えるレンタルサーバーにファイルを置き、パーミッションの設定をするだけでよい。マニュアルでは、さくらインターネットのレンタルサーバー([https://www.sakura.ne.jp/ さくらのレンタルサーバ])が推奨されている。 まず、公式サイトの[http://www.dodontof.com/index.php?option=com_content&view=article&id=246&Itemid=126 ダウンロードページ]から最新版または安定版のzipファイルをダウンロードし、展開する。さくらのレンタルサーバでアカウント名が「trpg_net」の場合、展開したファイルを以下のように配置し、パーミッションを設定する。 <pre> home +- trpg_net +- www | +- DodontoF (705) | | +- DodontoFServer.rb (705) | | +- log.txt (600) | | +- log.txt.0 (600) | | +- saveDataTempSpace (705) | | +- fileUploadSpace (705) | | +- replayDataUploadSpace (705) | +- imageUploadSpace (705) | +- smallImages (705) +- saveData (705) </pre> ファイルの配置およびパーミッション設定が完了したら、ブラウザから <code>DodontoF/DodontoFServer.rb</code> を開く。上記の例の場合、URLは <pre>http://trpg_net.sakura.ne.jp/DodontoF/DodontoFServer.rb</pre> となる。ファイルの配置およびパーミッション設定が正しくできていれば、以下のように表示される。 <syntaxhighlight lang="json"> ["「どどんとふ」の動作環境は正常に起動しています。"] </syntaxhighlight> 上記のメッセージが表示されたら、<code>DodontoF/DodontoF.swf</code> を開く。上記の例の場合、URLは <pre>http://trpg_net.sakura.ne.jp/DodontoF/DodontoF.swf</pre> となる。 === 大規模サーバー === レンタルサーバーを使う場合、快適に使用できる人数は10人程度までであり、それ以上の人数では負荷が重くなる。大規模なサーバーでは、以下のような構成とする例が多い。 * より高性能なサーバーやVPSを使う。 ** SSDを使う。 ** メモリに余裕があれば、RAMディスクを使う。 ** 必要に応じて、TCP/IPに関するLinuxカーネルのチューニングを行う。 * Webサーバーとしてnginxを使う。 * 最新のRubyを使う。 * FastCGIを使う。 ** spawn-fcgiなどでサーバープログラムを起動する。 ** Gem「fcgi」を使う。 * Gem「msgpack」を使う。 * 擬似cometモードを使わない。 設置の手順を解説している記事として、以下のものがある。 * [http://cre.jp/techblog/2016/01/27/dodontof-centos7-nginx-spawn/ クリエイターズネットワーク技術部ブログ » CentOS7+nginx+spawn-fcgi でどどんとふを動かす] ** [[TRPG.NET]]へのどどんとふの設置時の作業を基にしている。 * 大ちゃんのいろいろ雑記 - どどんとふをdebian+nginxで動かすやり方(nginxセットアップ編)@公式鯖3rdシリーズ ** [[どどんとふ公式鯖]]へのどどんとふ設置作業の記録。ハードウェアの性能を満たすのは難しいが、各要素は参考になる。 *# [https://www.taruki.com/wp/?p=6099 OS編] *# [https://www.taruki.com/wp/?p=6123 nginxセットアップ編] *# [https://www.taruki.com/wp/?p=6133 fcgi編] *# [https://www.taruki.com/wp/?p=6160 どどんとふ本体編] *# [https://www.taruki.com/wp/?p=6162 運用ツール編(最低限)] *# [https://www.taruki.com/wp/?p=6165 運用ツール編(その他)] *# [https://www.taruki.com/wp/?p=6182 運用ツール編(負荷グラフ)] == 脚注 == <references /> [[Category:TRPGツール]] {{DEFAULTSORT:ととんとふ}} 227879fa78c6ff5ea255782e26a455d7ecea9dbc メインページ 0 1 34 26 2019-06-23T15:31:02Z Ochaochaocha3 1 /* チャットプラットフォーム */ irc.cre.jp系を追加する wikitext text/x-wiki __NOTOC__ == ようこそ {{SITENAME}} へ == オープンソースのTRPGツールの開発や運用に関する情報をまとめるwikiです。TRPGのオンラインセッションに使われているツールの設置の仕方や使われている要素技術など、開発や運用に役立つ情報をまとめていきましょう。 現在、{{SITENAME}}には約 [[Special:Statistics|{{NUMBEROFARTICLES}}]] 本の記事があります。 == 主要なTRPGツール == === Webアプリケーション === * [[どどんとふ]] ** [[ひよんとふ]](ひよこどどんとふクライアント) * [[ユドナリウム]] * [[オンセンルーム]]([[TRPGオンラインセッションSNS]]) * [[ねこ卓]] * [[Quoridorn]] * [[Onset!]] * [[Saider]] * [[Saipage]] === ダイスボット === * [[BCDice]](ボーンズ&カーズ) ** [[BCDice-API]] ** [[discord-bcdicebot]] == 公開サーバー == * [[どどんとふ公式鯖]] * [[どどんとふむせる]] * [[コノスサーバー]] * [[TRPG.NET]] == チャットプラットフォーム == * [[Discord]] * [[IRC]] ** [[irc.cre.jp系]] [[Category:{{SITENAME}}]] {{DEFAULTSORT:めいんへえし}} 54ec1177bef5722d990419e1d24d9c2bff674883 50 34 2019-06-23T17:01:16Z Ochaochaocha3 1 wikitext text/x-wiki __NOTOC__ == ようこそ {{SITENAME}} へ == オープンソースのTRPGツールの開発や運用に関する情報をまとめるwikiです。ツールの設置の仕方や使われている要素技術など、開発や運用に役立つ情報をまとめていきましょう。 現在、{{SITENAME}}には約 [[Special:Statistics|{{NUMBEROFARTICLES}}]] 本の記事があります。 == 主要なTRPGツール == === Webアプリケーション === * [[どどんとふ]] ** [[ひよんとふ]](ひよこどどんとふクライアント) * [[ユドナリウム]] * [[オンセンルーム]]([[TRPGオンラインセッションSNS]]) * [[ねこ卓]] * [[Quoridorn]] * [[Onset!]] * [[Saider]] * [[Saipage]] === ダイスボット === * [[BCDice]](ボーンズ&カーズ) ** [[BCDice-API]] ** [[discord-bcdicebot]] == 公開サーバー == * [[どどんとふ公式鯖]] * [[どどんとふむせる]] * [[コノスサーバー]] * [[TRPG.NET]] == チャットプラットフォーム == * [[Discord]] * [[IRC]] ** [[irc.cre.jp系]] [[Category:{{SITENAME}}]] {{DEFAULTSORT:めいんへえし}} 60af316ae4d46d880385cbf37c13cc3dfd5ed733 BCDice/TRPGツールからの呼び出し方 0 15 35 2019-06-23T15:41:56Z Ochaochaocha3 1 ページの作成:「本ページ以下では、様々なオンラインセッションツールから現在の[[BCDice]]をどのように呼び出しているかをまとめる。 == Ruby…」 wikitext text/x-wiki 本ページ以下では、様々なオンラインセッションツールから現在の[[BCDice]]をどのように呼び出しているかをまとめる。 == Rubyで書かれたBCDiceを使用するツール == * [[/BCDice-API]] * [[/Onset!]] * [[/オンセンルーム]] * [[/どどんとふ]] == BCDice-APIを使用するツール == * [[Quoridorn]] ** v1.0.0b12:[https://github.com/HillTopTRPG/quoridorn-vue-cli-3/blob/bc39e134a367325a09c0e5257e5c50f9a91237a7/src/store/state_setting.ts#L51-L119 src/store/state_setting.ts#L51-L119] に呼び出す処理がある。 * [[Saipage]] ** コミット 723cbdb:[client/dice.ts](https://github.com/ysakasin/saipage/blob/723cbdbc20ad830e31dd6096bfcb39b14266bf49/client/dice.ts) に呼び出す処理がある。 == JavaScriptに変換したBCDiceを使用するツール == BCDiceをOpalでJavaScriptに変換して使用する。 * [[ねこ卓]]:[https://github.com/ukatama/bcdice-js bcdice-js]を使用する。 * [[ユドナリウム]] [[Category:BCDice]] {{DEFAULTSORT:TRPGつうるからのよひたしかた}} 23fdd6ce56d1b68837a0e0a1c5791af486d20241 36 35 2019-06-23T15:42:38Z Ochaochaocha3 1 /* BCDice-APIを使用するツール */ リンクを修正する wikitext text/x-wiki 本ページ以下では、様々なオンラインセッションツールから現在の[[BCDice]]をどのように呼び出しているかをまとめる。 == Rubyで書かれたBCDiceを使用するツール == * [[/BCDice-API]] * [[/Onset!]] * [[/オンセンルーム]] * [[/どどんとふ]] == BCDice-APIを使用するツール == * [[Quoridorn]] ** v1.0.0b12:[https://github.com/HillTopTRPG/quoridorn-vue-cli-3/blob/bc39e134a367325a09c0e5257e5c50f9a91237a7/src/store/state_setting.ts#L51-L119 src/store/state_setting.ts#L51-L119] に呼び出す処理がある。 * [[Saipage]] ** コミット 723cbdb:[https://github.com/ysakasin/saipage/blob/723cbdbc20ad830e31dd6096bfcb39b14266bf49/client/dice.ts client/dice.ts] に呼び出す処理がある。 == JavaScriptに変換したBCDiceを使用するツール == BCDiceをOpalでJavaScriptに変換して使用する。 * [[ねこ卓]]:[https://github.com/ukatama/bcdice-js bcdice-js]を使用する。 * [[ユドナリウム]] [[Category:BCDice]] {{DEFAULTSORT:TRPGつうるからのよひたしかた}} d0747bbef2cec4fedc4c9330b2999621d1c694d0 BCDice 0 16 37 2019-06-23T16:10:59Z Ochaochaocha3 1 ページの作成:「'''BCDice'''は、ダイスボットのひとつ。[[どどんとふ]]をはじめとした多くのTRPGツールに使用されている。現在は [https://twitter.com…」 wikitext text/x-wiki '''BCDice'''は、ダイスボットのひとつ。[[どどんとふ]]をはじめとした多くのTRPGツールに使用されている。現在は [https://twitter.com/torgtaitai たいたい竹流氏]を中心として開発が進められている。 * GitHubリポジトリ:[https://github.com/torgtaitai/BCDice torgtaitai/BCDice] * 使用技術:[[Ruby]] == 概要 == 多くの日本製ゲームシステムに対応したダイスボット。[[どどんとふ]]をはじめとした多くのTRPGツールに使用されており、広く普及している。 Perlで書かれた[[IRC]]ボットとして[https://twitter.com/Faceless192x Faceless氏]によって開発され、2008年に公開された。その後、2011年に[https://twitter.com/torgtaitai たいたい竹流氏]によって[[Ruby]]に移植され、どどんとふへの対応が強化された。新しいゲームシステムに対応したダイスボットの開発や内部処理の改善などで、両氏以外にも多くの者が開発に参加している。 開発当初はIRCボットとしての使用が前提だったが、Rubyへの移植以来、ライブラリとしての使用が増えた。ライブラリとしては「どどんとふのダイスボット」という位置付けだったが、2016年に[[Onset!]]でライブラリとして採用され、その他のTRPGツールでも利用されるようになってきた。TRPGツールからのBCDiceの利用を容易にするために、HTTP経由での利用を可能とする[[BCDice-API]]も開発されている。BCDice-APIは現在[[どどんとふ公式鯖]]に設置されており、TRPGツールの開発において気軽にBCDiceを利用することができる。 [[Category:ダイスボット]] [[Category:BCDice|*BCDice]] e1b632f60c634f7258c2d54d804e6b121524bf58 38 37 2019-06-23T16:11:47Z Ochaochaocha3 1 /* 関連項目 */ wikitext text/x-wiki '''BCDice'''は、ダイスボットのひとつ。[[どどんとふ]]をはじめとした多くのTRPGツールに使用されている。現在は [https://twitter.com/torgtaitai たいたい竹流氏]を中心として開発が進められている。 * GitHubリポジトリ:[https://github.com/torgtaitai/BCDice torgtaitai/BCDice] * 使用技術:[[Ruby]] == 概要 == 多くの日本製ゲームシステムに対応したダイスボット。[[どどんとふ]]をはじめとした多くのTRPGツールに使用されており、広く普及している。 Perlで書かれた[[IRC]]ボットとして[https://twitter.com/Faceless192x Faceless氏]によって開発され、2008年に公開された。その後、2011年に[https://twitter.com/torgtaitai たいたい竹流氏]によって[[Ruby]]に移植され、どどんとふへの対応が強化された。新しいゲームシステムに対応したダイスボットの開発や内部処理の改善などで、両氏以外にも多くの者が開発に参加している。 開発当初はIRCボットとしての使用が前提だったが、Rubyへの移植以来、ライブラリとしての使用が増えた。ライブラリとしては「どどんとふのダイスボット」という位置付けだったが、2016年に[[Onset!]]でライブラリとして採用され、その他のTRPGツールでも利用されるようになってきた。TRPGツールからのBCDiceの利用を容易にするために、HTTP経由での利用を可能とする[[BCDice-API]]も開発されている。BCDice-APIは現在[[どどんとふ公式鯖]]に設置されており、TRPGツールの開発において気軽にBCDiceを利用することができる。 == 関連項目 == * [[/TRPGツールからの呼び出し方]] [[Category:ダイスボット]] [[Category:BCDice|*BCDice]] fd51fe66269daa4435df71dd9c32684672f07704 39 38 2019-06-23T16:13:16Z Ochaochaocha3 1 ボーンズ&カーズ wikitext text/x-wiki '''BCDice'''(ボーンズ&カーズ)は、ダイスボットのひとつ。[[どどんとふ]]をはじめとした多くのTRPGツールに使用されている。現在は [https://twitter.com/torgtaitai たいたい竹流氏]を中心として開発が進められている。 * GitHubリポジトリ:[https://github.com/torgtaitai/BCDice torgtaitai/BCDice] * 使用技術:[[Ruby]] == 概要 == 多くの日本製ゲームシステムに対応したダイスボット。[[どどんとふ]]をはじめとした多くのTRPGツールに使用されており、広く普及している。 Perlで書かれた[[IRC]]ボットとして[https://twitter.com/Faceless192x Faceless氏]によって開発され、2008年に公開された。その後、2011年に[https://twitter.com/torgtaitai たいたい竹流氏]によって[[Ruby]]に移植され、どどんとふへの対応が強化された。新しいゲームシステムに対応したダイスボットの開発や内部処理の改善などで、両氏以外にも多くの者が開発に参加している。 開発当初はIRCボットとしての使用が前提だったが、Rubyへの移植以来、ライブラリとしての使用が増えた。ライブラリとしては「どどんとふのダイスボット」という位置付けだったが、2016年に[[Onset!]]でライブラリとして採用され、その他のTRPGツールでも利用されるようになってきた。TRPGツールからのBCDiceの利用を容易にするために、HTTP経由での利用を可能とする[[BCDice-API]]も開発されている。BCDice-APIは現在[[どどんとふ公式鯖]]に設置されており、TRPGツールの開発において気軽にBCDiceを利用することができる。 == 関連項目 == * [[/TRPGツールからの呼び出し方]] [[Category:ダイスボット]] [[Category:BCDice|*BCDice]] b12366772dd8486321acf3797b1aeb9ec8920db5 40 39 2019-06-23T16:13:53Z Ochaochaocha3 1 初公開版へのリンクを掲載する wikitext text/x-wiki '''BCDice'''(ボーンズ&カーズ)は、ダイスボットのひとつ。[[どどんとふ]]をはじめとした多くのTRPGツールに使用されている。現在は [https://twitter.com/torgtaitai たいたい竹流氏]を中心として開発が進められている。 * GitHubリポジトリ:[https://github.com/torgtaitai/BCDice torgtaitai/BCDice] * 使用技術:[[Ruby]] == 概要 == 多くの日本製ゲームシステムに対応したダイスボット。[[どどんとふ]]をはじめとした多くのTRPGツールに使用されており、広く普及している。 Perlで書かれた[[IRC]]ボットとして[https://twitter.com/Faceless192x Faceless氏]によって開発され、[http://faceless-tools.cocolog-nifty.com/blog/2008/02/ver1015_2788.html 2008年に公開された]。その後、2011年に[https://twitter.com/torgtaitai たいたい竹流氏]によって[[Ruby]]に移植され、どどんとふへの対応が強化された。新しいゲームシステムに対応したダイスボットの開発や内部処理の改善などで、両氏以外にも多くの者が開発に参加している。 開発当初はIRCボットとしての使用が前提だったが、Rubyへの移植以来、ライブラリとしての使用が増えた。ライブラリとしては「どどんとふのダイスボット」という位置付けだったが、2016年に[[Onset!]]でライブラリとして採用され、その他のTRPGツールでも利用されるようになってきた。TRPGツールからのBCDiceの利用を容易にするために、HTTP経由での利用を可能とする[[BCDice-API]]も開発されている。BCDice-APIは現在[[どどんとふ公式鯖]]に設置されており、TRPGツールの開発において気軽にBCDiceを利用することができる。 == 関連項目 == * [[/TRPGツールからの呼び出し方]] [[Category:ダイスボット]] [[Category:BCDice|*BCDice]] a5b675accea9baa99b98ec9a9e5b0cf5a3f358b3 101 40 2019-06-23T17:45:00Z Ochaochaocha3 1 概要テンプレートを使用する wikitext text/x-wiki {{TRPGツール概要 | 開発者 = ; Perl版 :[https://twitter.com/Faceless192x Faceless] ; Ruby版 :[https://twitter.com/torgtaitai たいたい竹流] | GitHubリポジトリ = [https://github.com/torgtaitai/BCDice torgtaitai/BCDice] | 使用技術 = [[Ruby]] }} '''BCDice'''(ボーンズ&カーズ)は、ダイスボットのひとつ。[[どどんとふ]]をはじめとした多くのTRPGツールに使用されている。現在は [https://twitter.com/torgtaitai たいたい竹流氏]を中心として開発が進められている。 == 概要 == 多くの日本製ゲームシステムに対応したダイスボット。[[どどんとふ]]をはじめとした多くのTRPGツールに使用されており、広く普及している。 Perlで書かれた[[IRC]]ボットとして[https://twitter.com/Faceless192x Faceless氏]によって開発され、[http://faceless-tools.cocolog-nifty.com/blog/2008/02/ver1015_2788.html 2008年に公開された]。その後、2011年に[https://twitter.com/torgtaitai たいたい竹流氏]によって[[Ruby]]に移植され、どどんとふへの対応が強化された。新しいゲームシステムに対応したダイスボットの開発や内部処理の改善などで、両氏以外にも多くの者が開発に参加している。 開発当初はIRCボットとしての使用が前提だったが、Rubyへの移植以来、ライブラリとしての使用が増えた。ライブラリとしては「どどんとふのダイスボット」という位置付けだったが、2016年に[[Onset!]]でライブラリとして採用され、その他のTRPGツールでも利用されるようになってきた。TRPGツールからのBCDiceの利用を容易にするために、HTTP経由での利用を可能とする[[BCDice-API]]も開発されている。BCDice-APIは現在[[どどんとふ公式鯖]]に設置されており、TRPGツールの開発において気軽にBCDiceを利用することができる。 == 関連項目 == * [[/TRPGツールからの呼び出し方]] [[Category:ダイスボット]] [[Category:BCDice|*BCDice]] 6d3b3bae82aa2cbbc7c963cd3b6099ab775c2ad4 BCDice/TRPGツールからの呼び出し方/BCDice-API 0 17 41 2019-06-23T16:18:35Z Ochaochaocha3 1 ページの作成:「[[BCDice-API]]からの[[BCDice]]の呼び出し方。[https://github.com/ysakasin/bcdice-api/releases/tag/0.6.2 v0.6.2]のソースコードを参考にしている。…」 wikitext text/x-wiki [[BCDice-API]]からの[[BCDice]]の呼び出し方。[https://github.com/ysakasin/bcdice-api/releases/tag/0.6.2 v0.6.2]のソースコードを参考にしている。 == server.rb L74-L78 == https://github.com/ysakasin/bcdice-api/blob/0dfd095a4c7befed58ffbb7eb880a9d729badf2a/server.rb#L74-L78 パス `/v1/diceroll` にリクエストが来たときの処理。ダイスロールを行う。 <syntaxhighlight lang="ruby"> get "/v1/diceroll" do result, secret, dices = diceroll(params[:system], params[:command]) jsonp ok: true, result: result, secret: secret, dices: dices end </syntaxhighlight> == server.rb L20-L42 == https://github.com/ysakasin/bcdice-api/blob/0dfd095a4c7befed58ffbb7eb880a9d729badf2a/server.rb#L20-L42 ダイスロールを行うメソッド。 <syntaxhighlight lang="ruby"> def diceroll(system, command) dicebot = BCDice::DICEBOTS[system] if dicebot.nil? raise UnsupportedDicebot end if command.nil? || command.empty? raise CommandError end bcdice = BCDiceMaker.new.newBcDice bcdice.setDiceBot(dicebot) bcdice.setMessage(command) bcdice.setCollectRandResult(true) result, secret = bcdice.dice_command dices = bcdice.getRandResults.map {|dice| {faces: dice[1], value: dice[0]}} if result.nil? raise CommandError end return result, secret, dices end </syntaxhighlight> [[Category:BCDice/TRPGツールからの呼び出し方]] 2627e6e14c08a1283e028a53200a39d3117c3b02 カテゴリ:BCDice/TRPGツールからの呼び出し方 14 18 42 2019-06-23T16:19:06Z Ochaochaocha3 1 ページの作成:「[[Category:BCDice]] {{DEFAULTSORT:TRPGつうるからのよひたしかた}}」 wikitext text/x-wiki [[Category:BCDice]] {{DEFAULTSORT:TRPGつうるからのよひたしかた}} 2f581b7e7e0defb9ed66eba0cdc35d6099ddbb0c カテゴリ:BCDice 14 19 43 2019-06-23T16:19:24Z Ochaochaocha3 1 ページの作成:「[[Category:ダイスボット]]」 wikitext text/x-wiki [[Category:ダイスボット]] 8788ecc66ba24cb10f7e740bcc840c2a55a1042c カテゴリ:ダイスボット 14 20 44 2019-06-23T16:19:59Z Ochaochaocha3 1 ページの作成:「ダイスロールを模倣するプログラムについてのページをまとめるカテゴリ。 {{DEFAULTSORT:たいすほつと}}」 wikitext text/x-wiki ダイスロールを模倣するプログラムについてのページをまとめるカテゴリ。 {{DEFAULTSORT:たいすほつと}} e8471de1368c069ee38333648e1fc82c756ebbbc BCDice/TRPGツールからの呼び出し方/Onset! 0 21 45 2019-06-23T16:26:18Z Ochaochaocha3 1 ページの作成:「[[Onset!]]からの[[BCDice]]の呼び出し方。[https://github.com/kiridaruma/Onset/releases/tag/v2.1.3 v2.1.3]のソースコードを参考にしている。 ツ…」 wikitext text/x-wiki [[Onset!]]からの[[BCDice]]の呼び出し方。[https://github.com/kiridaruma/Onset/releases/tag/v2.1.3 v2.1.3]のソースコードを参考にしている。 ツール本体は[[PHP]]製だが、[[Ruby]]で書かれた簡潔なラッパースクリプトを[[CGI]]で呼び出している。 __TOC__ == Onset/public_html/bcdice/roll.rb L31-L36 == https://github.com/kiridaruma/Onset/blob/297e66de6b799198cdf17036e12f89c7506fcd65/Onset/public_html/bcdice/roll.rb#L31-L36 クエリパラメータ <code>list=1</code> がついていた場合、ゲームシステム一覧を出力する。 <syntaxhighlight lang="ruby"> if(params['list'][0] == "1") $allGameTypes.each do |var| puts var + "\n" end exit end </syntaxhighlight> == Onset/public_html/bcdice/roll.rb L47-L55 == https://github.com/kiridaruma/Onset/blob/297e66de6b799198cdf17055e12f89c7506fcd65/Onset/public_html/bcdice/roll.rb#L47-L55 ダイスロールを行う。 <syntaxhighlight lang="ruby"> bcmaker = OnsetBCDiceMaker.new bcdice = bcmaker.newBcDice() bcdice.setGameByTitle(params['sys'][0]) bcdice.setMessage(params['text'][0]) bcdice.setNick('onset') hoge, foo = bcdice.dice_command puts hoge </syntaxhighlight> == Onset/public_html/bcdice/roll.rb L11-L24 == https://github.com/kiridaruma/Onset/blob/297e66de6b799198cdf17055e12f89c7506fcd65/Onset/public_html/bcdice/roll.rb#L11-L24 <code>OnsetBCDice</code> クラスは、Onset!のインターフェースに合わせてニックネームを設定する機能を付加している。<code>OnsetBCDiceMaker</code> クラスは、BCDiceのインスタンス作成時に <code>OnsetBCDice</code> クラスを使うようにする。 <syntaxhighlight lang="ruby"> class OnsetBCDiceMaker < BCDiceMaker def newBcDice bcdice = OnsetBCDice.new(self, @cardTrader, @diceBot, @counterInfos, @tableFileData) return bcdice end end class OnsetBCDice < BCDice def setNick(nick) @nick_e = nick end end </syntaxhighlight> [[Category:BCDice/TRPGツールからの呼び出し方]] 202438f5154e02f8e0c460bb9f469305e58bca32 BCDice/TRPGツールからの呼び出し方/オンセンルーム 0 22 46 2019-06-23T16:31:31Z Ochaochaocha3 1 ページの作成:「[[オンセンルーム]]からの[[BCDice]]の呼び出し方。v1.01.07のソースコードを参考にしている。 ツール本体は[[PHP]]製だが、[[Ruby]]…」 wikitext text/x-wiki [[オンセンルーム]]からの[[BCDice]]の呼び出し方。v1.01.07のソースコードを参考にしている。 ツール本体は[[PHP]]製だが、[[Ruby]]で書かれた簡潔なラッパースクリプトを[[CGI]]で呼び出している。 == rb/plug.rb L6-L13 == 初期設定。CGIで送られてきたフラグを変数に格納している。<code>"0"</code> だとダイスロールを行い、<code>"1"</code> だとダイスボットの説明文を取得する。 <syntaxhighlight lang="ruby"> cgi=CGI.new flag="0" #0=roll 1=descript bclocation='../BCDice/src' dicebot_name='DiceBot' dicebot_command='' if !cgi['flag'].nil? && !cgi['flag'].empty? then flag=cgi['flag'] end </syntaxhighlight> == rb/plug.rb L54-L60 == 共通設定。 <syntaxhighlight lang="ruby"> bcdiceMarker=OnsenBCDiceMaker.new bcdice=bcdiceMarker.newBcDice() bcdice.setCollectRandResult(true); if File.exist?(bclocation+'/extratables') then bcdice.setDir(bclocation+'/extratables',dicebot_name) end bcdice.setGameByTitle(dicebot_name) </syntaxhighlight> == rb/plug.rb L61-L71 == ダイスロールを行う。 <syntaxhighlight lang="ruby"> if flag !="1" then bcdice.setMessage(dicebot_command) gmsg=bcdice.getMessage res_msg,secret_flag=bcdice.dice_command res_rand=bcdice.getRandResults json_array={ 'secret_flag'=>secret_flag, 'gmsg'=>gmsg, 'res_rand'=>res_rand, 'res_msg'=>res_msg } </syntaxhighlight> == rb/plug.rb L72-L77 == ダイスボットの説明文を取得する。 <syntaxhighlight lang="ruby"> else ght=bcdice.gotHelpMessage json_array={ 'ght'=>ght } end </syntaxhighlight> == rb/plug.rb L40-L53 == 独自クラスの定義。必要な機能を呼び出しやすくしているようだ。 <syntaxhighlight lang="ruby"> class OnsenBCDiceMaker<BCDiceMaker def newBcDice bcdice=OnsenBCDice.new(self,@cardTrader,@diceBot,@counterInfos,@tableFileData) return bcdice end end class OnsenBCDice<BCDice def getMessage return @message end def gotHelpMessage return @diceBot.getHelpMessage end end </syntaxhighlight> == rb/plug.rb のソースコード == アーカイブを展開しないと見られないため、rb/plug.rb のソースコードを以下に掲載する。ただし、インデントのためのタブとスペースが混在していたため、スペースのみに直してある。 <syntaxhighlight lang="ruby"> #!/bin/ruby -Ku print("Content-Type: text/plain;charset=utf-8\n\n") require 'json.rb' require 'cgi.rb' cgi=CGI.new flag="0" #0=roll 1=descript bclocation='../BCDice/src' dicebot_name='DiceBot' dicebot_command='' if !cgi['flag'].nil? && !cgi['flag'].empty? then flag=cgi['flag'] end if !cgi['bclocation'].nil? && !cgi['bclocation'].empty? then bclocation=cgi['bclocation']+'src' end if !File.exist?(bclocation) then json_array={ 'error'=>'bac_location_error' } puts json_array.to_json exit end $LOAD_PATH<<bclocation if !cgi['dicebot_name'].nil? && !cgi['dicebot_name'].empty? then dicebot_name=cgi['dicebot_name'] end if !cgi['dicebot_command'].nil? && !cgi['dicebot_command'].empty? then dicebot_command=cgi['dicebot_command'] end if flag !="1" && dicebot_command=='' then json_array={ 'error'=>'not_exist_command' } puts json_array.to_json exit end require 'bcdiceCore.rb' require 'configBcDice.rb' class OnsenBCDiceMaker<BCDiceMaker def newBcDice bcdice=OnsenBCDice.new(self,@cardTrader,@diceBot,@counterInfos,@tableFileData) return bcdice end end class OnsenBCDice<BCDice def getMessage return @message end def gotHelpMessage return @diceBot.getHelpMessage end end bcdiceMarker=OnsenBCDiceMaker.new bcdice=bcdiceMarker.newBcDice() bcdice.setCollectRandResult(true); if File.exist?(bclocation+'/extratables') then bcdice.setDir(bclocation+'/extratables',dicebot_name) end bcdice.setGameByTitle(dicebot_name) if flag !="1" then bcdice.setMessage(dicebot_command) gmsg=bcdice.getMessage res_msg,secret_flag=bcdice.dice_command res_rand=bcdice.getRandResults json_array={ 'secret_flag'=>secret_flag, 'gmsg'=>gmsg, 'res_rand'=>res_rand, 'res_msg'=>res_msg } else ght=bcdice.gotHelpMessage json_array={ 'ght'=>ght } end puts json_array.to_json </syntaxhighlight> [[Category:BCDice/TRPGツールからの呼び出し方]] {{DEFAULTSORT:おんせんるうむ}} 8e932075867590176b754b22ceb6cef68201ec8b BCDice/TRPGツールからの呼び出し方/どどんとふ 0 23 47 2019-06-23T16:49:41Z Ochaochaocha3 1 DiceAdapterの途中まで wikitext text/x-wiki [[どどんとふ]]からの[[BCDice]]の呼び出し方。このページでは、Rubyで書かれたどどんとふのサーバのダイス関連の処理を扱う。[https://github.com/torgtaitai/DodontoF/tree/d3e4cc374885986efc761cfabbb19e4b35e815e0 v1.49.04.01]のソースコードを参考にしている。 == ファイルの役割 == どどんとふのサーバでは、ダイスボットとの通信の処理は以下のファイルに記述されている。 * [https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb src_ruby/dodontof/dice_adapter.rb]:BCDiceとのアダプタ * [https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/diceBotInfos.rb src_ruby/diceBotInfos.rb]:ダイスボットの情報を取得する処理 * [https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb DodontoFServer.rb]:サーバ本体 == src_ruby/dodontof/dice_adapter.rb:BCDiceとのアダプタ == https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb === L7-L10:<code>DiceAdapter#initialize</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L7-L10 アダプタを初期化する。 * <code>@dir</code>:部屋固有のデータ保存ディレクトリが設定される。詳細は「[[#L164-L185:@dice_adapter の初期化]]」で解説する。 * <code>@diceBotTablePrefix</code>:必ず <code>'diceBotTable_'</code> が設定される。 <syntaxhighlight lang="ruby"> def initialize(dir, prefix) @logger = DodontoF::Logger.instance @dir = dir @diceBotTablePrefix = prefix end </syntaxhighlight> === L13-L34:<code>DiceAdapter#rollDice</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L13-L34 ダイスロールを行う。メッセージ、ゲームシステム、出目を返すかが指定できる。結果のメッセージ、シークレットダイスかどうか、出目が返る。結果のメッセージの <code>'>'</code> は <code>'→'</code> に置換され、末尾の改行コードは削除される。 <syntaxhighlight lang="ruby"> def rollDice(params) require 'cgiDiceBot.rb' message = params['message'] gameType = params['gameType'] isNeedResult = params['isNeedResult'] @logger.debug(message, 'rollDice message') @logger.debug(gameType, 'rollDice gameType') bot = CgiDiceBot.new result, randResults = bot.roll(message, gameType, @dir, @diceBotTablePrefix, isNeedResult) result.gsub!(/>/, '→') result.sub!(/\r?\n?\Z/m, '') @logger.debug(result, 'rollDice result') @logger.debug(randResults, 'rollDice randResults') return result, bot.isSecret, randResults end </syntaxhighlight> === L36-L45:<code>DiceAdapter#getGameCommandInfos</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L36-L45 <syntaxhighlight lang="ruby"> def getGameCommandInfos require 'cgiDiceBot.rb' bot = CgiDiceBot.new @logger.debug(@dir, 'dir') commandInfos = bot.getGameCommandInfos(@dir, @diceBotTablePrefix) @logger.debug(commandInfos, "getGameCommandInfos End commandInfos") return commandInfos end </syntaxhighlight> == src_ruby/diceBotInfos.rb:ダイスボットの情報を取得する処理 == https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/diceBotInfos.rb === L69-L102:<code>DiceBotInfos.get</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/diceBotInfos.rb#L69-L102 <syntaxhighlight lang="ruby"> # ダイスボットの情報の一覧を取得する # @param [Array<String>] orderedGameNames 順序付けられたゲーム名の配列 # @param [Boolean] showAllDiceBots すべてのダイスボットを表示するか # @return [Array<Hash>] def self.get(orderedGameNames, showAllDiceBots) diceBots = DiceBotLoader.collectDiceBots # ゲーム名 => ダイスボットの対応を作る diceBotFor = Hash[ diceBots.map { |diceBot| [diceBot.gameName, diceBot] } ] toDiceBot = lambda { |gameName| diceBotFor[gameName] } orderedEnabledDiceBots = orderedGameNames. map(&toDiceBot). # ゲーム名が誤記されていた場合nilになるので除く compact orderedDiceBots = if showAllDiceBots disabledGameNames = diceBotFor.keys - orderedGameNames orderedDisabledDiceBots = disabledGameNames. sort. map(&toDiceBot) # 一覧に記載されていたゲーム→記載されていなかったゲームの順 orderedEnabledDiceBots + orderedDisabledDiceBots else orderedEnabledDiceBots end # 指定なし→各ゲーム→基本の順で返す [NONE_DICE_BOT_INFO] + orderedDiceBots.map(&:info) + [BASE_DICE_BOT_INFO] end </syntaxhighlight> === L104-150:<code>DiceBotInfos.withTableCommands</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/diceBotInfos.rb#L104-150 <syntaxhighlight lang="ruby"> # テーブルのコマンドも加えたダイスボットの情報の一覧を取得する # @param [Array<String>] orderedGameNames 順序付けられたゲーム名の配列 # @param [Boolean] showAllDiceBots すべてのダイスボットを表示するか # @param [Array<Hash>] commandInfos テーブルのコマンドの情報の配列 # @return [Array<Hash>] # # このメソッドは、ダイスボットから返された情報を破壊しない。 def self.withTableCommands(orderedGameNames, showAllDiceBots, commandInfos) diceBotInfos = self.get(orderedGameNames, showAllDiceBots) # ゲームタイプ => ダイスボット情報のインデックスの対応を作る diceBotInfoIndexFor = Hash[ diceBotInfos.each_with_index.map { |info, i| [info[KEY_GAME_TYPE], i] } ] allGameTypes = diceBotInfoIndexFor.keys # ゲームタイプ => 追加するコマンドの一覧の対応を作る commandsToAdd = commandInfos.reduce({}) { |acc, commandInfo| gameType = commandInfo[KEY_GAME_TYPE] command = commandInfo[KEY_COMMAND] # ゲームタイプ未指定ならすべてのゲームタイプに追加する targetGameTypes = gameType.empty? ? allGameTypes : [gameType] targetGameTypes.each do |targetGameType| acc[targetGameType] ||= [] acc[targetGameType] << command end acc } commandsToAdd.each do |gameType, commands| diceBotInfoIndex = diceBotInfoIndexFor[gameType] next unless diceBotInfoIndex originalInfo = diceBotInfos[diceBotInfoIndex] # ダイスボットから返された情報を破壊しないようにして更新する diceBotInfos[diceBotInfoIndex] = originalInfo.merge({ KEY_PREFIXS => originalInfo[KEY_PREFIXS] + commands }) end diceBotInfos end </syntaxhighlight> == DodontoFServer.rb:サーバ本体 == https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb === L164-L185:<code>@dice_adapter</code> の初期化 === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L164-L185 <syntaxhighlight lang="ruby"> def initialize(saveDirInfo, cgiParams) @cgiParams = cgiParams @saveDirInfo = saveDirInfo @logger = DodontoF::Logger.instance @cgi = nil @jsonpCallBack = nil @isWebIf = false @isRecordEmpty = false initSaveFiles(getRequestData('room')) @dice_adapter = DodontoF::DiceAdapter.new(getDiceBotExtraTableDirName, 'diceBotTable_') @fullBackupFileBaseName = "DodontoFFullBackup" @allSaveDataFileExt = '.tar.gz' @defaultAllSaveData = 'default.sav' @defaultChatPallete = 'default.cpd' @card = nil end </syntaxhighlight> <code>getDiceBotExtraTableDirName</code>([https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3727-L3729 L3727-L3729])では、<code>getRoomLocalSpaceDirName</code>([https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3262-L3265 L3262-L3265])、<code>getRoomLocalSpaceDirNameByRoomNo</code>([https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3267-L3273 L3267-L3273])を経由して、<code>$imageUploadDir</code> の中の部屋固有のディレクトリを返す。 === L1193-L1210:<code>getWebIfServerInfo</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L1193-L1210 Webインターフェースのサーバ情報を返すコマンド。<code>getDiceBotInfos</code> でダイスボットの情報を取得する。 <syntaxhighlight lang="ruby"> def getWebIfServerInfo() jsonData = { "maxRoom" => ($saveDataMaxCount - 1), 'isNeedCreatePassword' => (not $createPlayRoomPassword.empty?), 'result' => 'OK', } if( getWebIfRequestBoolean("card", false) ) cardInfos = getCardsInfo.collectCardTypeAndTypeName($cardOrder) jsonData["cardInfos"] = cardInfos end if( getWebIfRequestBoolean("dice", false) ) jsonData['diceBotInfos'] = getDiceBotInfos() end return jsonData end </syntaxhighlight> === L2090:<code>getLoginInfo</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2090 ダイスボット情報の取得を行う。 <syntaxhighlight lang="ruby"> diceBotInfos = getDiceBotInfos() </syntaxhighlight> === L2266-L2280:<code>getDiceBotInfos</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2266-L2280 ダイスボット情報取得処理の実装。部屋に入っているかどうかで、テーブルのコマンドも含めた情報を返すかどうかを決定している。 <syntaxhighlight lang="ruby"> def getDiceBotInfos @logger.debug("getDiceBotInfos() Begin") require 'diceBotInfos' orderedGameNames = $diceBotOrder.split("\n") if @saveDirInfo.getSaveDataDirIndex != -1 DiceBotInfos.withTableCommands(orderedGameNames, $isDisplayAllDice, @dice_adapter.getGameCommandInfos) else DiceBotInfos.get(orderedGameNames, $isDisplayAllDice) end end </syntaxhighlight> === L2542-2556:<code>save</code>, <code>getDiceTableData</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2542-2556 部屋のデータの保存時に、独自の表についての情報を取得する。 <syntaxhighlight lang="ruby"> def save() isAddPlayRoomInfo = true extension = @@saveFileExtension addInfos = {} addInfos[$diceBotTableSaveKey] = getDiceTableData() saveSelectFiles($saveFiles.keys, extension, isAddPlayRoomInfo, addInfos) end def getDiceTableData() tableInfos = @dice_adapter.getBotTableInfosFromDir tableInfos.each{|i| i.delete('fileName') } return tableInfos end </syntaxhighlight> === L2806-L2817:<code>getBotTableInfos</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2806-L2817 独自の表についての情報を取得する。 <syntaxhighlight lang="ruby"> def getBotTableInfos() @logger.debug("getBotTableInfos Begin") result = { "resultText"=> "OK", } result["tableInfos"] = @dice_adapter.getBotTableInfosFromDir @logger.debug(result, "result") @logger.debug("getBotTableInfos End") return result end </syntaxhighlight> === L2819-L2835:<code>addBotTable</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2819-L2835 独自の表を追加する。 <syntaxhighlight lang="ruby"> def addBotTable() result = {} params = getParamsFromRequestData() result['resultText'] = @dice_adapter.addBotTableMain(params) if( result['resultText'] != "OK" ) return result end @logger.debug("addBotTableMain called") result = getBotTableInfos() @logger.debug(result, "addBotTable result") return result end </syntaxhighlight> === L2837-L2849:<code>changeBotTable</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2837-L2849 独自の表を変更する。 <syntaxhighlight lang="ruby"> def changeBotTable() params = getParamsFromRequestData() result = {} result['resultText'] = @dice_adapter.changeBotTableMain(params) if( result['resultText'] != "OK" ) return result end result = getBotTableInfos() return result end </syntaxhighlight> === L2851-L2855:<code>removeBotTable</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2851-L2855 独自の表を削除する。 <syntaxhighlight lang="ruby"> def removeBotTable() params = getParamsFromRequestData() @dice_adapter.removeBotTableMain(params) return getBotTableInfos() end </syntaxhighlight> === L3458-L3459:<code>loadSaveFileDataFilterByTargets</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3458-L3459 セーブデータの部分読み込み処理の一部。独自の表を読み込む。 <syntaxhighlight lang="ruby"> when "diceBotTable" loadDiceBotTable(jsonData) </syntaxhighlight> === L3511-L3531:<code>loadDiceBotTable</code>, <code>getDiceBotTableString</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3511-L3531 独自の表を読み込む。 <syntaxhighlight lang="ruby"> def loadDiceBotTable(jsonData) data = jsonData[$diceBotTableSaveKey] return if( data.nil? ) data.each do |info| info['table'] = getDiceBotTableString(info['table']) @dice_adapter.addBotTableMain(info) end end def getDiceBotTableString(table) lines = [] table.each do |line| lines << line.join(":") end return lines.join("\n") end </syntaxhighlight> === L3632-L3657:<code>sendDiceBotChatMessage</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3632-L3657 BCDiceにコマンドを送る処理。<code>回数 コマンド</code> という形で送信回数が指定されていた場合は、指定された回数だけコマンドをBCDiceに送る。 <syntaxhighlight lang="ruby"> def sendDiceBotChatMessage @logger.debug('sendDiceBotChatMessage') params = getParamsFromRequestData() repeatCount = getDiceBotRepeatCount(params) results = [] repeatCount.times do |i| paramsClone = params.clone paramsClone['message'] += " \##{ i + 1 }" if( repeatCount > 1 ) result = sendDiceBotChatMessageOnece( paramsClone ) @logger.debug(result, "sendDiceBotChatMessageOnece result") next if( result.nil? ) results << result end @logger.debug(results, "sendDiceBotChatMessage results") return results end </syntaxhighlight> === L3659-L3669:<code>getDiceBotRepeatCount</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3659-L3669 コマンド送信回数を1〜20回に制限する。最近のRubyでは <code>(params['repeatCount'] || 1).clamp(1, 20)</code> と簡潔に書ける。 <syntaxhighlight lang="ruby"> def getDiceBotRepeatCount(params) repeatCountLimit = 20 repeatCount = params['repeatCount'] repeatCount ||= 1 repeatCount = 1 if( repeatCount < 1 ) repeatCount = repeatCountLimit if( repeatCount > repeatCountLimit ) return repeatCount end </syntaxhighlight> === L3672-L3709:<code>sendDiceBotChatMessageOnece</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3672-L3709 BCDiceに1回分(おそらく <code>Onece</code> は <code>once</code> のスペルミス)のコマンドを送る処理。<code>getRollDiceResult</code> でダイスロールした結果を取得する。<code>sendChatMessageByChatData</code>([https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3817-3839 L3817-3839])で、その結果を含むメッセージを送信する。 <syntaxhighlight lang="ruby"> def sendDiceBotChatMessageOnece(params) rolledMessage, isSecret, secretMessage = getRollDiceResult( params ) senderName = params['name'] unless /\t/ === senderName state = params['state'] senderName += ("\t" + state) unless( state.empty? ) end chatData = { "senderName" => senderName, "message" => rolledMessage, "color" => params['color'], "uniqueId" => '0', "channel" => params['channel'] } sendto = params['sendto'] unless( sendto.nil? ) chatData['sendto'] = sendto chatData['sendtoName'] = sendtoName end @logger.debug(chatData, 'sendDiceBotChatMessageOnece chatData') sendChatMessageByChatData(chatData) result = nil if( isSecret ) params['isSecret'] = isSecret params['message'] = secretMessage result = params end return result end </syntaxhighlight> === L3672-L3725:<code>getRollDiceResult</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3672-L3709 BCDiceでダイスを振る。シークレットダイスかどうかも考慮してメッセージを加工し、返す。 <syntaxhighlight lang="ruby"> def getRollDiceResult( params ) params['originalMessage'] = params['message'] rollResult, isSecret, randResults = @dice_adapter.rollDice(params) secretMessage = "" if( isSecret ) secretMessage = params['message'] + rollResult else params['message'] += rollResult end rolledMessage = getRolledMessage(params, isSecret, randResults) return rolledMessage, isSecret, secretMessage end </syntaxhighlight> === L3732-L3762:<code>getRolledMessage</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3732-L3709 ダイスロールの結果を入力として、どどんとふクライアントでの表示に必要な情報を付加する。シークレットダイスの場合に結果を隠すことと、「!」の数でサイコロを強調できるようにすることが目的のようだ。 <syntaxhighlight lang="ruby"> def getRolledMessage(params, isSecret, randResults) @logger.debug("getRolledMessage Begin") @logger.debug(isSecret, "isSecret") @logger.debug(randResults, "randResults") if( isSecret ) params['message'] = getLanguageKey('secretDice') randResults = randResults.collect{|value, max| [0, 0] } end message = params['message'] if( randResults.nil? ) @logger.debug("randResults is nil") return message end data = { "chatMessage" => message, "randResults" => randResults, "uniqueId" => params['uniqueId'], "power" => getDiceBotPower(params), } text = "###CutInCommand:rollVisualDice###" + getJsonString(data) @logger.debug(text, "getRolledMessage End text") return text end </syntaxhighlight> [[Category:BCDice/TRPGツールからの呼び出し方]] {{DEFAULTSORT:ととんとふ}} f45943a3584b857ee22fd4eb209ea8ba23a935bd 48 47 2019-06-23T16:51:28Z Ochaochaocha3 1 /* 各ファイルの役割 */ wikitext text/x-wiki [[どどんとふ]]からの[[BCDice]]の呼び出し方。このページでは、Rubyで書かれたどどんとふのサーバのダイス関連の処理を扱う。[https://github.com/torgtaitai/DodontoF/tree/d3e4cc374885986efc761cfabbb19e4b35e815e0 v1.49.04.01]のソースコードを参考にしている。 == 各ファイルの役割 == どどんとふのサーバでは、ダイスボットとの通信の処理は以下のファイルに記述されている。 * [https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb src_ruby/dodontof/dice_adapter.rb]:BCDiceとのアダプタ * [https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/diceBotInfos.rb src_ruby/diceBotInfos.rb]:ダイスボットの情報を取得する処理 * [https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb DodontoFServer.rb]:サーバ本体 == src_ruby/dodontof/dice_adapter.rb:BCDiceとのアダプタ == https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb === L7-L10:<code>DiceAdapter#initialize</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L7-L10 アダプタを初期化する。 * <code>@dir</code>:部屋固有のデータ保存ディレクトリが設定される。詳細は「[[#L164-L185:@dice_adapter の初期化]]」で解説する。 * <code>@diceBotTablePrefix</code>:必ず <code>'diceBotTable_'</code> が設定される。 <syntaxhighlight lang="ruby"> def initialize(dir, prefix) @logger = DodontoF::Logger.instance @dir = dir @diceBotTablePrefix = prefix end </syntaxhighlight> === L13-L34:<code>DiceAdapter#rollDice</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L13-L34 ダイスロールを行う。メッセージ、ゲームシステム、出目を返すかが指定できる。結果のメッセージ、シークレットダイスかどうか、出目が返る。結果のメッセージの <code>'>'</code> は <code>'→'</code> に置換され、末尾の改行コードは削除される。 <syntaxhighlight lang="ruby"> def rollDice(params) require 'cgiDiceBot.rb' message = params['message'] gameType = params['gameType'] isNeedResult = params['isNeedResult'] @logger.debug(message, 'rollDice message') @logger.debug(gameType, 'rollDice gameType') bot = CgiDiceBot.new result, randResults = bot.roll(message, gameType, @dir, @diceBotTablePrefix, isNeedResult) result.gsub!(/>/, '→') result.sub!(/\r?\n?\Z/m, '') @logger.debug(result, 'rollDice result') @logger.debug(randResults, 'rollDice randResults') return result, bot.isSecret, randResults end </syntaxhighlight> === L36-L45:<code>DiceAdapter#getGameCommandInfos</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L36-L45 <syntaxhighlight lang="ruby"> def getGameCommandInfos require 'cgiDiceBot.rb' bot = CgiDiceBot.new @logger.debug(@dir, 'dir') commandInfos = bot.getGameCommandInfos(@dir, @diceBotTablePrefix) @logger.debug(commandInfos, "getGameCommandInfos End commandInfos") return commandInfos end </syntaxhighlight> == src_ruby/diceBotInfos.rb:ダイスボットの情報を取得する処理 == https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/diceBotInfos.rb === L69-L102:<code>DiceBotInfos.get</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/diceBotInfos.rb#L69-L102 <syntaxhighlight lang="ruby"> # ダイスボットの情報の一覧を取得する # @param [Array<String>] orderedGameNames 順序付けられたゲーム名の配列 # @param [Boolean] showAllDiceBots すべてのダイスボットを表示するか # @return [Array<Hash>] def self.get(orderedGameNames, showAllDiceBots) diceBots = DiceBotLoader.collectDiceBots # ゲーム名 => ダイスボットの対応を作る diceBotFor = Hash[ diceBots.map { |diceBot| [diceBot.gameName, diceBot] } ] toDiceBot = lambda { |gameName| diceBotFor[gameName] } orderedEnabledDiceBots = orderedGameNames. map(&toDiceBot). # ゲーム名が誤記されていた場合nilになるので除く compact orderedDiceBots = if showAllDiceBots disabledGameNames = diceBotFor.keys - orderedGameNames orderedDisabledDiceBots = disabledGameNames. sort. map(&toDiceBot) # 一覧に記載されていたゲーム→記載されていなかったゲームの順 orderedEnabledDiceBots + orderedDisabledDiceBots else orderedEnabledDiceBots end # 指定なし→各ゲーム→基本の順で返す [NONE_DICE_BOT_INFO] + orderedDiceBots.map(&:info) + [BASE_DICE_BOT_INFO] end </syntaxhighlight> === L104-150:<code>DiceBotInfos.withTableCommands</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/diceBotInfos.rb#L104-150 <syntaxhighlight lang="ruby"> # テーブルのコマンドも加えたダイスボットの情報の一覧を取得する # @param [Array<String>] orderedGameNames 順序付けられたゲーム名の配列 # @param [Boolean] showAllDiceBots すべてのダイスボットを表示するか # @param [Array<Hash>] commandInfos テーブルのコマンドの情報の配列 # @return [Array<Hash>] # # このメソッドは、ダイスボットから返された情報を破壊しない。 def self.withTableCommands(orderedGameNames, showAllDiceBots, commandInfos) diceBotInfos = self.get(orderedGameNames, showAllDiceBots) # ゲームタイプ => ダイスボット情報のインデックスの対応を作る diceBotInfoIndexFor = Hash[ diceBotInfos.each_with_index.map { |info, i| [info[KEY_GAME_TYPE], i] } ] allGameTypes = diceBotInfoIndexFor.keys # ゲームタイプ => 追加するコマンドの一覧の対応を作る commandsToAdd = commandInfos.reduce({}) { |acc, commandInfo| gameType = commandInfo[KEY_GAME_TYPE] command = commandInfo[KEY_COMMAND] # ゲームタイプ未指定ならすべてのゲームタイプに追加する targetGameTypes = gameType.empty? ? allGameTypes : [gameType] targetGameTypes.each do |targetGameType| acc[targetGameType] ||= [] acc[targetGameType] << command end acc } commandsToAdd.each do |gameType, commands| diceBotInfoIndex = diceBotInfoIndexFor[gameType] next unless diceBotInfoIndex originalInfo = diceBotInfos[diceBotInfoIndex] # ダイスボットから返された情報を破壊しないようにして更新する diceBotInfos[diceBotInfoIndex] = originalInfo.merge({ KEY_PREFIXS => originalInfo[KEY_PREFIXS] + commands }) end diceBotInfos end </syntaxhighlight> == DodontoFServer.rb:サーバ本体 == https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb === L164-L185:<code>@dice_adapter</code> の初期化 === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L164-L185 <syntaxhighlight lang="ruby"> def initialize(saveDirInfo, cgiParams) @cgiParams = cgiParams @saveDirInfo = saveDirInfo @logger = DodontoF::Logger.instance @cgi = nil @jsonpCallBack = nil @isWebIf = false @isRecordEmpty = false initSaveFiles(getRequestData('room')) @dice_adapter = DodontoF::DiceAdapter.new(getDiceBotExtraTableDirName, 'diceBotTable_') @fullBackupFileBaseName = "DodontoFFullBackup" @allSaveDataFileExt = '.tar.gz' @defaultAllSaveData = 'default.sav' @defaultChatPallete = 'default.cpd' @card = nil end </syntaxhighlight> <code>getDiceBotExtraTableDirName</code>([https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3727-L3729 L3727-L3729])では、<code>getRoomLocalSpaceDirName</code>([https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3262-L3265 L3262-L3265])、<code>getRoomLocalSpaceDirNameByRoomNo</code>([https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3267-L3273 L3267-L3273])を経由して、<code>$imageUploadDir</code> の中の部屋固有のディレクトリを返す。 === L1193-L1210:<code>getWebIfServerInfo</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L1193-L1210 Webインターフェースのサーバ情報を返すコマンド。<code>getDiceBotInfos</code> でダイスボットの情報を取得する。 <syntaxhighlight lang="ruby"> def getWebIfServerInfo() jsonData = { "maxRoom" => ($saveDataMaxCount - 1), 'isNeedCreatePassword' => (not $createPlayRoomPassword.empty?), 'result' => 'OK', } if( getWebIfRequestBoolean("card", false) ) cardInfos = getCardsInfo.collectCardTypeAndTypeName($cardOrder) jsonData["cardInfos"] = cardInfos end if( getWebIfRequestBoolean("dice", false) ) jsonData['diceBotInfos'] = getDiceBotInfos() end return jsonData end </syntaxhighlight> === L2090:<code>getLoginInfo</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2090 ダイスボット情報の取得を行う。 <syntaxhighlight lang="ruby"> diceBotInfos = getDiceBotInfos() </syntaxhighlight> === L2266-L2280:<code>getDiceBotInfos</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2266-L2280 ダイスボット情報取得処理の実装。部屋に入っているかどうかで、テーブルのコマンドも含めた情報を返すかどうかを決定している。 <syntaxhighlight lang="ruby"> def getDiceBotInfos @logger.debug("getDiceBotInfos() Begin") require 'diceBotInfos' orderedGameNames = $diceBotOrder.split("\n") if @saveDirInfo.getSaveDataDirIndex != -1 DiceBotInfos.withTableCommands(orderedGameNames, $isDisplayAllDice, @dice_adapter.getGameCommandInfos) else DiceBotInfos.get(orderedGameNames, $isDisplayAllDice) end end </syntaxhighlight> === L2542-2556:<code>save</code>, <code>getDiceTableData</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2542-2556 部屋のデータの保存時に、独自の表についての情報を取得する。 <syntaxhighlight lang="ruby"> def save() isAddPlayRoomInfo = true extension = @@saveFileExtension addInfos = {} addInfos[$diceBotTableSaveKey] = getDiceTableData() saveSelectFiles($saveFiles.keys, extension, isAddPlayRoomInfo, addInfos) end def getDiceTableData() tableInfos = @dice_adapter.getBotTableInfosFromDir tableInfos.each{|i| i.delete('fileName') } return tableInfos end </syntaxhighlight> === L2806-L2817:<code>getBotTableInfos</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2806-L2817 独自の表についての情報を取得する。 <syntaxhighlight lang="ruby"> def getBotTableInfos() @logger.debug("getBotTableInfos Begin") result = { "resultText"=> "OK", } result["tableInfos"] = @dice_adapter.getBotTableInfosFromDir @logger.debug(result, "result") @logger.debug("getBotTableInfos End") return result end </syntaxhighlight> === L2819-L2835:<code>addBotTable</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2819-L2835 独自の表を追加する。 <syntaxhighlight lang="ruby"> def addBotTable() result = {} params = getParamsFromRequestData() result['resultText'] = @dice_adapter.addBotTableMain(params) if( result['resultText'] != "OK" ) return result end @logger.debug("addBotTableMain called") result = getBotTableInfos() @logger.debug(result, "addBotTable result") return result end </syntaxhighlight> === L2837-L2849:<code>changeBotTable</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2837-L2849 独自の表を変更する。 <syntaxhighlight lang="ruby"> def changeBotTable() params = getParamsFromRequestData() result = {} result['resultText'] = @dice_adapter.changeBotTableMain(params) if( result['resultText'] != "OK" ) return result end result = getBotTableInfos() return result end </syntaxhighlight> === L2851-L2855:<code>removeBotTable</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2851-L2855 独自の表を削除する。 <syntaxhighlight lang="ruby"> def removeBotTable() params = getParamsFromRequestData() @dice_adapter.removeBotTableMain(params) return getBotTableInfos() end </syntaxhighlight> === L3458-L3459:<code>loadSaveFileDataFilterByTargets</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3458-L3459 セーブデータの部分読み込み処理の一部。独自の表を読み込む。 <syntaxhighlight lang="ruby"> when "diceBotTable" loadDiceBotTable(jsonData) </syntaxhighlight> === L3511-L3531:<code>loadDiceBotTable</code>, <code>getDiceBotTableString</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3511-L3531 独自の表を読み込む。 <syntaxhighlight lang="ruby"> def loadDiceBotTable(jsonData) data = jsonData[$diceBotTableSaveKey] return if( data.nil? ) data.each do |info| info['table'] = getDiceBotTableString(info['table']) @dice_adapter.addBotTableMain(info) end end def getDiceBotTableString(table) lines = [] table.each do |line| lines << line.join(":") end return lines.join("\n") end </syntaxhighlight> === L3632-L3657:<code>sendDiceBotChatMessage</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3632-L3657 BCDiceにコマンドを送る処理。<code>回数 コマンド</code> という形で送信回数が指定されていた場合は、指定された回数だけコマンドをBCDiceに送る。 <syntaxhighlight lang="ruby"> def sendDiceBotChatMessage @logger.debug('sendDiceBotChatMessage') params = getParamsFromRequestData() repeatCount = getDiceBotRepeatCount(params) results = [] repeatCount.times do |i| paramsClone = params.clone paramsClone['message'] += " \##{ i + 1 }" if( repeatCount > 1 ) result = sendDiceBotChatMessageOnece( paramsClone ) @logger.debug(result, "sendDiceBotChatMessageOnece result") next if( result.nil? ) results << result end @logger.debug(results, "sendDiceBotChatMessage results") return results end </syntaxhighlight> === L3659-L3669:<code>getDiceBotRepeatCount</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3659-L3669 コマンド送信回数を1〜20回に制限する。最近のRubyでは <code>(params['repeatCount'] || 1).clamp(1, 20)</code> と簡潔に書ける。 <syntaxhighlight lang="ruby"> def getDiceBotRepeatCount(params) repeatCountLimit = 20 repeatCount = params['repeatCount'] repeatCount ||= 1 repeatCount = 1 if( repeatCount < 1 ) repeatCount = repeatCountLimit if( repeatCount > repeatCountLimit ) return repeatCount end </syntaxhighlight> === L3672-L3709:<code>sendDiceBotChatMessageOnece</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3672-L3709 BCDiceに1回分(おそらく <code>Onece</code> は <code>once</code> のスペルミス)のコマンドを送る処理。<code>getRollDiceResult</code> でダイスロールした結果を取得する。<code>sendChatMessageByChatData</code>([https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3817-3839 L3817-3839])で、その結果を含むメッセージを送信する。 <syntaxhighlight lang="ruby"> def sendDiceBotChatMessageOnece(params) rolledMessage, isSecret, secretMessage = getRollDiceResult( params ) senderName = params['name'] unless /\t/ === senderName state = params['state'] senderName += ("\t" + state) unless( state.empty? ) end chatData = { "senderName" => senderName, "message" => rolledMessage, "color" => params['color'], "uniqueId" => '0', "channel" => params['channel'] } sendto = params['sendto'] unless( sendto.nil? ) chatData['sendto'] = sendto chatData['sendtoName'] = sendtoName end @logger.debug(chatData, 'sendDiceBotChatMessageOnece chatData') sendChatMessageByChatData(chatData) result = nil if( isSecret ) params['isSecret'] = isSecret params['message'] = secretMessage result = params end return result end </syntaxhighlight> === L3672-L3725:<code>getRollDiceResult</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3672-L3709 BCDiceでダイスを振る。シークレットダイスかどうかも考慮してメッセージを加工し、返す。 <syntaxhighlight lang="ruby"> def getRollDiceResult( params ) params['originalMessage'] = params['message'] rollResult, isSecret, randResults = @dice_adapter.rollDice(params) secretMessage = "" if( isSecret ) secretMessage = params['message'] + rollResult else params['message'] += rollResult end rolledMessage = getRolledMessage(params, isSecret, randResults) return rolledMessage, isSecret, secretMessage end </syntaxhighlight> === L3732-L3762:<code>getRolledMessage</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3732-L3709 ダイスロールの結果を入力として、どどんとふクライアントでの表示に必要な情報を付加する。シークレットダイスの場合に結果を隠すことと、「!」の数でサイコロを強調できるようにすることが目的のようだ。 <syntaxhighlight lang="ruby"> def getRolledMessage(params, isSecret, randResults) @logger.debug("getRolledMessage Begin") @logger.debug(isSecret, "isSecret") @logger.debug(randResults, "randResults") if( isSecret ) params['message'] = getLanguageKey('secretDice') randResults = randResults.collect{|value, max| [0, 0] } end message = params['message'] if( randResults.nil? ) @logger.debug("randResults is nil") return message end data = { "chatMessage" => message, "randResults" => randResults, "uniqueId" => params['uniqueId'], "power" => getDiceBotPower(params), } text = "###CutInCommand:rollVisualDice###" + getJsonString(data) @logger.debug(text, "getRolledMessage End text") return text end </syntaxhighlight> [[Category:BCDice/TRPGツールからの呼び出し方]] {{DEFAULTSORT:ととんとふ}} 19497794ed54c214e63cdc0ea85e86b67a5527eb テンプレート:Documentation 10 24 52 51 2019-06-23T17:10:31Z Ochaochaocha3 1 1版 をインポートしました wikitext text/x-wiki {{#invoke:Documentation|main|_content={{ {{#invoke:Documentation|contentTitle}}}}}}<noinclude> <!-- Add categories and interwikis to the /doc subpage, not here! --> </noinclude> 9393ef9c27de27bd17c258c2f85cd0f32f196e54 テンプレート:Infobox 10 25 54 53 2019-06-23T17:10:31Z Ochaochaocha3 1 1版 をインポートしました wikitext text/x-wiki {{#invoke:Infobox/former|main}}<noinclude>{{Documentation}}</noinclude> b659e81634b4e58d9f585cba78a1628dca1ecf2f テンプレート:Ombox 10 26 56 55 2019-06-23T17:10:31Z Ochaochaocha3 1 1版 をインポートしました wikitext text/x-wiki {{#invoke:Message box|ombox}}<noinclude> {{Documentation}} <!-- Add categories and interwikis to the /doc subpage, not here! --> </noinclude> c29c4228977e10054168af738403c6843d92f9a4 テンプレート:概要テンプレート・編集 10 27 58 57 2019-06-23T17:10:31Z Ochaochaocha3 1 1版 をインポートしました wikitext text/x-wiki <noinclude>{{DEFAULTSORT:かいようてんふれえと へんしゆう}} [[Category:テンプレート]]</noinclude>{{Ombox | type = content | text = このテンプレートを編集する場合は「'''{{#if:{{{1|}}}|[{{fullurl:特別:概要テンプレートエディタ|wptemplate-page-to-load={{{1}}}}} 特別:概要テンプレートエディタ]|[[特別:概要テンプレートエディタ]]}}'''」を使用してください。 }} d7b95d757606321ca88e552c9d31904f1067e695 モジュール:Arguments 828 28 60 59 2019-06-23T17:10:32Z Ochaochaocha3 1 1版 をインポートしました Scribunto text/plain -- This module provides easy processing of arguments passed to Scribunto from -- #invoke. It is intended for use by other Lua modules, and should not be -- called from #invoke directly. local libraryUtil = require('libraryUtil') local checkType = libraryUtil.checkType local arguments = {} -- Generate four different tidyVal functions, so that we don't have to check the -- options every time we call it. local function tidyValDefault(key, val) if type(val) == 'string' then val = val:match('^%s*(.-)%s*$') if val == '' then return nil else return val end else return val end end local function tidyValTrimOnly(key, val) if type(val) == 'string' then return val:match('^%s*(.-)%s*$') else return val end end local function tidyValRemoveBlanksOnly(key, val) if type(val) == 'string' then if val:find('%S') then return val else return nil end else return val end end local function tidyValNoChange(key, val) return val end local function matchesTitle(given, title) local tp = type( given ) return (tp == 'string' or tp == 'number') and mw.title.new( given ).prefixedText == title end local translate_mt = { __index = function(t, k) return k end } function arguments.getArgs(frame, options) checkType('getArgs', 1, frame, 'table', true) checkType('getArgs', 2, options, 'table', true) frame = frame or {} options = options or {} --[[ -- Set up argument translation. --]] options.translate = options.translate or {} if getmetatable(options.translate) == nil then setmetatable(options.translate, translate_mt) end if options.backtranslate == nil then options.backtranslate = {} for k,v in pairs(options.translate) do options.backtranslate[v] = k end end if options.backtranslate and getmetatable(options.backtranslate) == nil then setmetatable(options.backtranslate, { __index = function(t, k) if options.translate[k] ~= k then return nil else return k end end }) end --[[ -- Get the argument tables. If we were passed a valid frame object, get the -- frame arguments (fargs) and the parent frame arguments (pargs), depending -- on the options set and on the parent frame's availability. If we weren't -- passed a valid frame object, we are being called from another Lua module -- or from the debug console, so assume that we were passed a table of args -- directly, and assign it to a new variable (luaArgs). --]] local fargs, pargs, luaArgs if type(frame.args) == 'table' and type(frame.getParent) == 'function' then if options.wrappers then --[[ -- The wrappers option makes Module:Arguments look up arguments in -- either the frame argument table or the parent argument table, but -- not both. This means that users can use either the #invoke syntax -- or a wrapper template without the loss of performance associated -- with looking arguments up in both the frame and the parent frame. -- Module:Arguments will look up arguments in the parent frame -- if it finds the parent frame's title in options.wrapper; -- otherwise it will look up arguments in the frame object passed -- to getArgs. --]] local parent = frame:getParent() if not parent then fargs = frame.args else local title = parent:getTitle():gsub('/sandbox$', '') local found = false if matchesTitle(options.wrappers, title) then found = true elseif type(options.wrappers) == 'table' then for _,v in pairs(options.wrappers) do if matchesTitle(v, title) then found = true break end end end -- We test for false specifically here so that nil (the default) acts like true. if found or options.frameOnly == false then pargs = parent.args end if not found or options.parentOnly == false then fargs = frame.args end end else -- options.wrapper isn't set, so check the other options. if not options.parentOnly then fargs = frame.args end if not options.frameOnly then local parent = frame:getParent() pargs = parent and parent.args or nil end end if options.parentFirst then fargs, pargs = pargs, fargs end else luaArgs = frame end -- Set the order of precedence of the argument tables. If the variables are -- nil, nothing will be added to the table, which is how we avoid clashes -- between the frame/parent args and the Lua args. local argTables = {fargs} argTables[#argTables + 1] = pargs argTables[#argTables + 1] = luaArgs --[[ -- Generate the tidyVal function. If it has been specified by the user, we -- use that; if not, we choose one of four functions depending on the -- options chosen. This is so that we don't have to call the options table -- every time the function is called. --]] local tidyVal = options.valueFunc if tidyVal then if type(tidyVal) ~= 'function' then error( "bad value assigned to option 'valueFunc'" .. '(function expected, got ' .. type(tidyVal) .. ')', 2 ) end elseif options.trim ~= false then if options.removeBlanks ~= false then tidyVal = tidyValDefault else tidyVal = tidyValTrimOnly end else if options.removeBlanks ~= false then tidyVal = tidyValRemoveBlanksOnly else tidyVal = tidyValNoChange end end --[[ -- Set up the args, metaArgs and nilArgs tables. args will be the one -- accessed from functions, and metaArgs will hold the actual arguments. Nil -- arguments are memoized in nilArgs, and the metatable connects all of them -- together. --]] local args, metaArgs, nilArgs, metatable = {}, {}, {}, {} setmetatable(args, metatable) local function mergeArgs(tables) --[[ -- Accepts multiple tables as input and merges their keys and values -- into one table. If a value is already present it is not overwritten; -- tables listed earlier have precedence. We are also memoizing nil -- values, which can be overwritten if they are 's' (soft). --]] for _, t in ipairs(tables) do for key, val in pairs(t) do if metaArgs[key] == nil and nilArgs[key] ~= 'h' then local tidiedVal = tidyVal(key, val) if tidiedVal == nil then nilArgs[key] = 's' else metaArgs[key] = tidiedVal end end end end end --[[ -- Define metatable behaviour. Arguments are memoized in the metaArgs table, -- and are only fetched from the argument tables once. Fetching arguments -- from the argument tables is the most resource-intensive step in this -- module, so we try and avoid it where possible. For this reason, nil -- arguments are also memoized, in the nilArgs table. Also, we keep a record -- in the metatable of when pairs and ipairs have been called, so we do not -- run pairs and ipairs on the argument tables more than once. We also do -- not run ipairs on fargs and pargs if pairs has already been run, as all -- the arguments will already have been copied over. --]] metatable.__index = function (t, key) --[[ -- Fetches an argument when the args table is indexed. First we check -- to see if the value is memoized, and if not we try and fetch it from -- the argument tables. When we check memoization, we need to check -- metaArgs before nilArgs, as both can be non-nil at the same time. -- If the argument is not present in metaArgs, we also check whether -- pairs has been run yet. If pairs has already been run, we return nil. -- This is because all the arguments will have already been copied into -- metaArgs by the mergeArgs function, meaning that any other arguments -- must be nil. --]] if type(key) == 'string' then key = options.translate[key] end local val = metaArgs[key] if val ~= nil then return val elseif metatable.donePairs or nilArgs[key] then return nil end for _, argTable in ipairs(argTables) do local argTableVal = tidyVal(key, argTable[key]) if argTableVal ~= nil then metaArgs[key] = argTableVal return argTableVal end end nilArgs[key] = 'h' return nil end metatable.__newindex = function (t, key, val) -- This function is called when a module tries to add a new value to the -- args table, or tries to change an existing value. if type(key) == 'string' then key = options.translate[key] end if options.readOnly then error( 'could not write to argument table key "' .. tostring(key) .. '"; the table is read-only', 2 ) elseif options.noOverwrite and args[key] ~= nil then error( 'could not write to argument table key "' .. tostring(key) .. '"; overwriting existing arguments is not permitted', 2 ) elseif val == nil then --[[ -- If the argument is to be overwritten with nil, we need to erase -- the value in metaArgs, so that __index, __pairs and __ipairs do -- not use a previous existing value, if present; and we also need -- to memoize the nil in nilArgs, so that the value isn't looked -- up in the argument tables if it is accessed again. --]] metaArgs[key] = nil nilArgs[key] = 'h' else metaArgs[key] = val end end local function translatenext(invariant) local k, v = next(invariant.t, invariant.k) invariant.k = k if k == nil then return nil elseif type(k) ~= 'string' or not options.backtranslate then return k, v else local backtranslate = options.backtranslate[k] if backtranslate == nil then -- Skip this one. This is a tail call, so this won't cause stack overflow return translatenext(invariant) else return backtranslate, v end end end metatable.__pairs = function () -- Called when pairs is run on the args table. if not metatable.donePairs then mergeArgs(argTables) metatable.donePairs = true end return translatenext, { t = metaArgs } end local function inext(t, i) -- This uses our __index metamethod local v = t[i + 1] if v ~= nil then return i + 1, v end end metatable.__ipairs = function (t) -- Called when ipairs is run on the args table. return inext, t, 0 end return args end return arguments 3134ecce8429b810d445e29eae115e2ae4c36c53 モジュール:Category handler 828 29 62 61 2019-06-23T17:10:32Z Ochaochaocha3 1 1版 をインポートしました Scribunto text/plain -------------------------------------------------------------------------------- -- -- -- CATEGORY HANDLER -- -- -- -- This module implements the {{category handler}} template in Lua, -- -- with a few improvements: all namespaces and all namespace aliases -- -- are supported, and namespace names are detected automatically for -- -- the local wiki. This module requires [[Module:Namespace detect]] -- -- and [[Module:Yesno]] to be available on the local wiki. It can be -- -- configured for different wikis by altering the values in -- -- [[Module:Category handler/config]], and pages can be blacklisted -- -- from categorisation by using [[Module:Category handler/blacklist]]. -- -- -- -------------------------------------------------------------------------------- -- Load required modules local yesno = require('Module:Yesno') -- Lazily load things we don't always need local mShared, mappings local p = {} -------------------------------------------------------------------------------- -- Helper functions -------------------------------------------------------------------------------- local function trimWhitespace(s, removeBlanks) if type(s) ~= 'string' then return s end s = s:match('^%s*(.-)%s*$') if removeBlanks then if s ~= '' then return s else return nil end else return s end end -------------------------------------------------------------------------------- -- CategoryHandler class -------------------------------------------------------------------------------- local CategoryHandler = {} CategoryHandler.__index = CategoryHandler function CategoryHandler.new(data, args) local obj = setmetatable({ _data = data, _args = args }, CategoryHandler) -- Set the title object do local pagename = obj:parameter('demopage') local success, titleObj if pagename then success, titleObj = pcall(mw.title.new, pagename) end if success and titleObj then obj.title = titleObj if titleObj == mw.title.getCurrentTitle() then obj._usesCurrentTitle = true end else obj.title = mw.title.getCurrentTitle() obj._usesCurrentTitle = true end end -- Set suppression parameter values for _, key in ipairs{'nocat', 'categories'} do local value = obj:parameter(key) value = trimWhitespace(value, true) obj['_' .. key] = yesno(value) end do local subpage = obj:parameter('subpage') local category2 = obj:parameter('category2') if type(subpage) == 'string' then subpage = mw.ustring.lower(subpage) end if type(category2) == 'string' then subpage = mw.ustring.lower(category2) end obj._subpage = trimWhitespace(subpage, true) obj._category2 = trimWhitespace(category2) -- don't remove blank values end return obj end function CategoryHandler:parameter(key) local parameterNames = self._data.parameters[key] local pntype = type(parameterNames) if pntype == 'string' or pntype == 'number' then return self._args[parameterNames] elseif pntype == 'table' then for _, name in ipairs(parameterNames) do local value = self._args[name] if value ~= nil then return value end end return nil else error(string.format( 'invalid config key "%s"', tostring(key) ), 2) end end function CategoryHandler:isSuppressedByArguments() return -- See if a category suppression argument has been set. self._nocat == true or self._categories == false or ( self._category2 and self._category2 ~= self._data.category2Yes and self._category2 ~= self._data.category2Negative ) -- Check whether we are on a subpage, and see if categories are -- suppressed based on our subpage status. or self._subpage == self._data.subpageNo and self.title.isSubpage or self._subpage == self._data.subpageOnly and not self.title.isSubpage end function CategoryHandler:shouldSkipBlacklistCheck() -- Check whether the category suppression arguments indicate we -- should skip the blacklist check. return self._nocat == false or self._categories == true or self._category2 == self._data.category2Yes end function CategoryHandler:matchesBlacklist() if self._usesCurrentTitle then return self._data.currentTitleMatchesBlacklist else mShared = mShared or require('Module:Category handler/shared') return mShared.matchesBlacklist( self.title.prefixedText, mw.loadData('Module:Category handler/blacklist') ) end end function CategoryHandler:isSuppressed() -- Find if categories are suppressed by either the arguments or by -- matching the blacklist. return self:isSuppressedByArguments() or not self:shouldSkipBlacklistCheck() and self:matchesBlacklist() end function CategoryHandler:getNamespaceParameters() if self._usesCurrentTitle then return self._data.currentTitleNamespaceParameters else if not mappings then mShared = mShared or require('Module:Category handler/shared') mappings = mShared.getParamMappings(true) -- gets mappings with mw.loadData end return mShared.getNamespaceParameters( self.title, mappings ) end end function CategoryHandler:namespaceParametersExist() -- Find whether any namespace parameters have been specified. -- We use the order "all" --> namespace params --> "other" as this is what -- the old template did. if self:parameter('all') then return true end if not mappings then mShared = mShared or require('Module:Category handler/shared') mappings = mShared.getParamMappings(true) -- gets mappings with mw.loadData end for ns, params in pairs(mappings) do for i, param in ipairs(params) do if self._args[param] then return true end end end if self:parameter('other') then return true end return false end function CategoryHandler:getCategories() local params = self:getNamespaceParameters() local nsCategory for i, param in ipairs(params) do local value = self._args[param] if value ~= nil then nsCategory = value break end end if nsCategory ~= nil or self:namespaceParametersExist() then -- Namespace parameters exist - advanced usage. if nsCategory == nil then nsCategory = self:parameter('other') end local ret = {self:parameter('all')} local numParam = tonumber(nsCategory) if numParam and numParam >= 1 and math.floor(numParam) == numParam then -- nsCategory is an integer ret[#ret + 1] = self._args[numParam] else ret[#ret + 1] = nsCategory end if #ret < 1 then return nil else return table.concat(ret) end elseif self._data.defaultNamespaces[self.title.namespace] then -- Namespace parameters don't exist, simple usage. return self._args[1] end return nil end -------------------------------------------------------------------------------- -- Exports -------------------------------------------------------------------------------- local p = {} function p._exportClasses() -- Used for testing purposes. return { CategoryHandler = CategoryHandler } end function p._main(args, data) data = data or mw.loadData('Module:Category handler/data') local handler = CategoryHandler.new(data, args) if handler:isSuppressed() then return nil end return handler:getCategories() end function p.main(frame, data) data = data or mw.loadData('Module:Category handler/data') local args = require('Module:Arguments').getArgs(frame, { wrappers = data.wrappers, valueFunc = function (k, v) v = trimWhitespace(v) if type(k) == 'number' then if v ~= '' then return v else return nil end else return v end end }) return p._main(args, data) end return p b74dd63857b24904ac452429b11213f18647471f モジュール:Category handler/blacklist 828 30 64 63 2019-06-23T17:10:32Z Ochaochaocha3 1 1版 をインポートしました Scribunto text/plain -- This module contains the blacklist used by [[Module:Category handler]]. -- Pages that match Lua patterns in this list will not be categorised unless -- categorisation is explicitly requested. return { '^メインページ$', -- don't categorise the main page. -- Don't categorise the following pages or their subpages. -- "%f[/\0]" matches if the next character is "/" or the end of the string. '^Wikipedia:Cascade%-protected items%f[/\0]', '^User:UBX%f[/\0]', -- The userbox "template" space. '^User talk:UBX%f[/\0]', -- Don't categorise subpages of these pages, but allow -- categorisation of the base page. '^Wikipedia:Template メッセージの一覧/.*$', '/過去ログ' -- Don't categorise archives. } 62012c87cb111349a8583a72af07a75c2d1216b7 モジュール:Category handler/config 828 31 66 65 2019-06-23T17:10:33Z Ochaochaocha3 1 1版 をインポートしました Scribunto text/plain -------------------------------------------------------------------------------- -- [[Module:Category handler]] configuration data -- -- Language-specific parameter names and values can be set here. -- -- For blacklist config, see [[Module:Category handler/blacklist]]. -- -------------------------------------------------------------------------------- local cfg = {} -- Don't edit this line. -------------------------------------------------------------------------------- -- Start configuration data -- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -- Parameter names -- -- These configuration items specify custom parameter names. -- -- To add one extra name, you can use this format: -- -- -- -- foo = 'parameter name', -- -- -- -- To add multiple names, you can use this format: -- -- -- -- foo = {'parameter name 1', 'parameter name 2', 'parameter name 3'}, -- -------------------------------------------------------------------------------- cfg.parameters = { -- The nocat and categories parameter suppress -- categorisation. They are used with Module:Yesno, and work as follows: -- -- cfg.nocat: -- Result of yesno() Effect -- true Categorisation is suppressed -- false Categorisation is allowed, and -- the blacklist check is skipped -- nil Categorisation is allowed -- -- cfg.categories: -- Result of yesno() Effect -- true Categorisation is allowed, and -- the blacklist check is skipped -- false Categorisation is suppressed -- nil Categorisation is allowed nocat = 'nocat', categories = 'categories', -- The parameter name for the legacy "category2" parameter. This skips the -- blacklist if set to the cfg.category2Yes value, and suppresses -- categorisation if present but equal to anything other than -- cfg.category2Yes or cfg.category2Negative. category2 = 'category2', -- cfg.subpage is the parameter name to specify how to behave on subpages. subpage = 'subpage', -- The parameter for data to return in all namespaces. all = 'all', -- The parameter name for data to return if no data is specified for the -- namespace that is detected. other = 'other', -- The parameter name used to specify a page other than the current page; -- used for testing and demonstration. demopage = 'page', } -------------------------------------------------------------------------------- -- Parameter values -- -- These are set values that can be used with certain parameters. Only one -- -- value can be specified, like this: -- -- -- -- cfg.foo = 'value name' -- -- -------------------------------------------------------------------------------- -- The following settings are used with the cfg.category2 parameter. Setting -- cfg.category2 to cfg.category2Yes skips the blacklist, and if cfg.category2 -- is present but equal to anything other than cfg.category2Yes or -- cfg.category2Negative then it supresses cateogrisation. cfg.category2Yes = 'yes' cfg.category2Negative = '¬' -- The following settings are used with the cfg.subpage parameter. -- cfg.subpageNo is the value to specify to not categorise on subpages; -- cfg.subpageOnly is the value to specify to only categorise on subpages. cfg.subpageNo = 'no' cfg.subpageOnly = 'only' -------------------------------------------------------------------------------- -- Default namespaces -- -- This is a table of namespaces to categorise by default. The keys are the -- -- namespace numbers. -- -------------------------------------------------------------------------------- cfg.defaultNamespaces = { [ 0] = true, -- main [ 6] = true, -- file [ 12] = true, -- help [ 14] = true, -- category [100] = true, -- portal [108] = true, -- book } -------------------------------------------------------------------------------- -- Wrappers -- -- This is a wrapper template or a list of wrapper templates to be passed to -- -- [[Module:Arguments]]. -- -------------------------------------------------------------------------------- cfg.wrappers = 'Template:Category handler' -------------------------------------------------------------------------------- -- End configuration data -- -------------------------------------------------------------------------------- return cfg -- Don't edit this line. 373cd107b13a5b00e6a1b7e66a749f12502c849d モジュール:Category handler/data 828 32 68 67 2019-06-23T17:10:33Z Ochaochaocha3 1 1版 をインポートしました Scribunto text/plain -- This module assembles data to be passed to [[Module:Category handler]] using -- mw.loadData. This includes the configuration data and whether the current -- page matches the title blacklist. local data = require('Module:Category handler/config') local mShared = require('Module:Category handler/shared') local blacklist = require('Module:Category handler/blacklist') local title = mw.title.getCurrentTitle() data.currentTitleMatchesBlacklist = mShared.matchesBlacklist( title.prefixedText, blacklist ) data.currentTitleNamespaceParameters = mShared.getNamespaceParameters( title, mShared.getParamMappings() ) return data abbc68048ff698e88dda06b64ecf384bbf583120 モジュール:Category handler/shared 828 33 70 69 2019-06-23T17:10:33Z Ochaochaocha3 1 1版 をインポートしました Scribunto text/plain -- This module contains shared functions used by [[Module:Category handler]] -- and its submodules. local p = {} function p.matchesBlacklist(page, blacklist) for i, pattern in ipairs(blacklist) do local match = mw.ustring.match(page, pattern) if match then return true end end return false end function p.getParamMappings(useLoadData) local dataPage = 'Module:Namespace detect/data' if useLoadData then return mw.loadData(dataPage).mappings else return require(dataPage).mappings end end function p.getNamespaceParameters(titleObj, mappings) -- We don't use title.nsText for the namespace name because it adds -- underscores. local mappingsKey if titleObj.isTalkPage then mappingsKey = 'talk' else mappingsKey = mw.site.namespaces[titleObj.namespace].name end mappingsKey = mw.ustring.lower(mappingsKey) return mappings[mappingsKey] or {} end return p d2d5de1a031e6ce97c242cbfa8afe7a92cb9eca5 モジュール:Documentation 828 34 72 71 2019-06-23T17:10:34Z Ochaochaocha3 1 1版 をインポートしました Scribunto text/plain -- This module implements {{documentation}}. -- Get required modules. local getArgs = require('Module:Arguments').getArgs local messageBox = require('Module:Message box') -- Get the config table. local cfg = mw.loadData('Module:Documentation/config') local p = {} -- Often-used functions. local ugsub = mw.ustring.gsub ---------------------------------------------------------------------------- -- Helper functions -- -- These are defined as local functions, but are made available in the p -- table for testing purposes. ---------------------------------------------------------------------------- local function message(cfgKey, valArray, expectType) --[[ -- Gets a message from the cfg table and formats it if appropriate. -- The function raises an error if the value from the cfg table is not -- of the type expectType. The default type for expectType is 'string'. -- If the table valArray is present, strings such as $1, $2 etc. in the -- message are substituted with values from the table keys [1], [2] etc. -- For example, if the message "foo-message" had the value 'Foo $2 bar $1.', -- message('foo-message', {'baz', 'qux'}) would return "Foo qux bar baz." --]] local msg = cfg[cfgKey] expectType = expectType or 'string' if type(msg) ~= expectType then error('メッセージ: メッセージCFGの入力エラー。' .. cfgKey .. ' (' .. expectType .. ' expected, got ' .. type(msg) .. ')', 2) end if not valArray then return msg end local function getMessageVal(match) match = tonumber(match) return valArray[match] or error('メッセージ: メッセージCFGにおいて$' .. match .. 'キーへの値の入力が必要です。' .. cfgKey, 4) end local ret = ugsub(msg, '$([1-9][0-9]*)', getMessageVal) return ret end p.message = message local function makeWikilink(page, display) if display then return mw.ustring.format('[[%s|%s]]', page, display) else return mw.ustring.format('[[%s]]', page) end end p.makeWikilink = makeWikilink local function makeCategoryLink(cat, sort) local catns = mw.site.namespaces[14].name return makeWikilink(catns .. ':' .. cat, sort) end p.makeCategoryLink = makeCategoryLink local function makeUrlLink(url, display) return mw.ustring.format('[%s %s]', url, display) end p.makeUrlLink = makeUrlLink local function makeToolbar(...) local ret = {} local lim = select('#', ...) if lim < 1 then return nil end for i = 1, lim do ret[#ret + 1] = select(i, ...) end return '<small style="font-style: normal;">(' .. table.concat(ret, ' &#124; ') .. ')</small>' end p.makeToolbar = makeToolbar ---------------------------------------------------------------------------- -- Argument processing ---------------------------------------------------------------------------- local function makeInvokeFunc(funcName) return function (frame) local args = getArgs(frame, { valueFunc = function (key, value) if type(value) == 'string' then value = value:match('^%s*(.-)%s*$') -- Remove whitespace. if key == 'heading' or value ~= '' then return value else return nil end else return value end end }) return p[funcName](args) end end ---------------------------------------------------------------------------- -- Main function ---------------------------------------------------------------------------- p.main = makeInvokeFunc('_main') function p._main(args) --[[ -- This function defines logic flow for the module. -- @args - table of arguments passed by the user -- -- Messages: -- 'main-div-id' --> 'template-documentation' -- 'main-div-classes' --> 'template-documentation iezoomfix' --]] local env = p.getEnvironment(args) local root = mw.html.create() root -- :wikitext(p.protectionTemplate(env)) :wikitext(p.sandboxNotice(args, env)) -- This div tag is from {{documentation/start box}}, but moving it here -- so that we don't have to worry about unclosed tags. :tag('div') :attr('id', message('main-div-id')) :addClass(message('main-div-classes')) :newline() :wikitext(p._startBox(args, env)) :wikitext(p._content(args, env)) :css('background-color', '#ecfcf4') :css('border', '1px solid #aaa') :css('padding', '1em') :css('margin', '1em 0 0 0') :css('clear', 'both') :tag('div') :css('clear', 'both') -- So right or left floating items don't stick out of the doc box. :newline() :done() :done() :wikitext(p._endBox(args, env)) :wikitext(p.addTrackingCategories(env)) return tostring(root) end ---------------------------------------------------------------------------- -- Environment settings ---------------------------------------------------------------------------- function p.getEnvironment(args) --[[ -- Returns a table with information about the environment, including title objects and other namespace- or -- path-related data. -- @args - table of arguments passed by the user -- -- Title objects include: -- env.title - the page we are making documentation for (usually the current title) -- env.templateTitle - the template (or module, file, etc.) -- env.docTitle - the /doc subpage. -- env.sandboxTitle - the /sandbox subpage. -- env.testcasesTitle - the /testcases subpage. -- env.printTitle - the print version of the template, located at the /Print subpage. -- -- Data includes: -- env.protectionLevels - the protection levels table of the title object. -- env.subjectSpace - the number of the title's subject namespace. -- env.docSpace - the number of the namespace the title puts its documentation in. -- env.docpageBase - the text of the base page of the /doc, /sandbox and /testcases pages, with namespace. -- env.compareUrl - URL of the Special:ComparePages page comparing the sandbox with the template. -- -- All table lookups are passed through pcall so that errors are caught. If an error occurs, the value -- returned will be nil. --]] local env, envFuncs = {}, {} -- Set up the metatable. If triggered we call the corresponding function in the envFuncs table. The value -- returned by that function is memoized in the env table so that we don't call any of the functions -- more than once. (Nils won't be memoized.) setmetatable(env, { __index = function (t, key) local envFunc = envFuncs[key] if envFunc then local success, val = pcall(envFunc) if success then env[key] = val -- Memoise the value. return val end end return nil end }) function envFuncs.title() -- The title object for the current page, or a test page passed with args.page. local title local titleArg = args.page if titleArg then title = mw.title.new(titleArg) else title = mw.title.getCurrentTitle() end return title end function envFuncs.templateTitle() --[[ -- The template (or module, etc.) title object. -- Messages: -- 'sandbox-subpage' --> 'sandbox' -- 'testcases-subpage' --> 'testcases' --]] local subjectSpace = env.subjectSpace local title = env.title local subpage = title.subpageText if subpage == message('sandbox-subpage') or subpage == message('testcases-subpage') then return mw.title.makeTitle(subjectSpace, title.baseText) else return mw.title.makeTitle(subjectSpace, title.text) end end function envFuncs.docTitle() --[[ -- Title object of the /doc subpage. -- Messages: -- 'doc-subpage' --> 'doc' --]] local title = env.title local docname = args[1] -- User-specified doc page. local docpage if docname then docpage = docname else docpage = env.docpageBase .. '/' .. message('doc-subpage') end return mw.title.new(docpage) end function envFuncs.sandboxTitle() --[[ -- Title object for the /sandbox subpage. -- Messages: -- 'sandbox-subpage' --> 'sandbox' --]] return mw.title.new(env.docpageBase .. '/' .. message('sandbox-subpage')) end function envFuncs.testcasesTitle() --[[ -- Title object for the /testcases subpage. -- Messages: -- 'testcases-subpage' --> 'testcases' --]] return mw.title.new(env.docpageBase .. '/' .. message('testcases-subpage')) end function envFuncs.printTitle() --[[ -- Title object for the /Print subpage. -- Messages: -- 'print-subpage' --> 'Print' --]] return env.templateTitle:subPageTitle(message('print-subpage')) end -- function envFuncs.protectionLevels() -- The protection levels table of the title object. -- return env.title.protectionLevels -- end function envFuncs.subjectSpace() -- The subject namespace number. return mw.site.namespaces[env.title.namespace].subject.id end function envFuncs.docSpace() -- The documentation namespace number. For most namespaces this is the same as the -- subject namespace. However, pages in the Article, File, MediaWiki or Category -- namespaces must have their /doc, /sandbox and /testcases pages in talk space. local subjectSpace = env.subjectSpace if subjectSpace == 0 or subjectSpace == 6 or subjectSpace == 8 or subjectSpace == 14 then return subjectSpace + 1 else return subjectSpace end end function envFuncs.docpageBase() -- The base page of the /doc, /sandbox, and /testcases subpages. -- For some namespaces this is the talk page, rather than the template page. local templateTitle = env.templateTitle local docSpace = env.docSpace local docSpaceText = mw.site.namespaces[docSpace].name -- Assemble the link. docSpace is never the main namespace, so we can hardcode the colon. return docSpaceText .. ':' .. templateTitle.text end function envFuncs.compareUrl() -- Diff link between the sandbox and the main template using [[Special:ComparePages]]. local templateTitle = env.templateTitle local sandboxTitle = env.sandboxTitle if templateTitle.exists and sandboxTitle.exists then local compareUrl = mw.uri.fullUrl( 'Special:ComparePages', {page1 = templateTitle.prefixedText, page2 = sandboxTitle.prefixedText} ) return tostring(compareUrl) else return nil end end return env end ---------------------------------------------------------------------------- -- Auxiliary templates ---------------------------------------------------------------------------- function p.sandboxNotice(args, env) --[=[ -- Generates a sandbox notice for display above sandbox pages. -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- -- Messages: -- 'sandbox-notice-image' --> '[[Image:Sandbox.svg|50px|alt=|link=]]' -- 'sandbox-notice-blurb' --> 'This is the $1 for $2.' -- 'sandbox-notice-diff-blurb' --> 'This is the $1 for $2 ($3).' -- 'sandbox-notice-pagetype-template' --> '[[Wikipedia:Template test cases|template sandbox]] page' -- 'sandbox-notice-pagetype-module' --> '[[Wikipedia:Template test cases|module sandbox]] page' -- 'sandbox-notice-pagetype-other' --> 'sandbox page' -- 'sandbox-notice-compare-link-display' --> 'diff' -- 'sandbox-notice-testcases-blurb' --> 'See also the companion subpage for $1.' -- 'sandbox-notice-testcases-link-display' --> 'test cases' -- 'sandbox-category' --> 'Template sandboxes' --]=] local title = env.title local sandboxTitle = env.sandboxTitle local templateTitle = env.templateTitle local subjectSpace = env.subjectSpace if not (subjectSpace and title and sandboxTitle and templateTitle and mw.title.equals(title, sandboxTitle)) then return nil end -- Build the table of arguments to pass to {{ombox}}. We need just two fields, "image" and "text". local omargs = {} omargs.image = message('sandbox-notice-image') -- Get the text. We start with the opening blurb, which is something like -- "This is the template sandbox for [[Template:Foo]] (diff)." local text = '' local pagetype if subjectSpace == 10 then pagetype = message('sandbox-notice-pagetype-template') elseif subjectSpace == 828 then pagetype = message('sandbox-notice-pagetype-module') else pagetype = message('sandbox-notice-pagetype-other') end local templateLink = makeWikilink(templateTitle.prefixedText) local compareUrl = env.compareUrl if compareUrl then local compareDisplay = message('sandbox-notice-compare-link-display') local compareLink = makeUrlLink(compareUrl, compareDisplay) text = text .. message('sandbox-notice-diff-blurb', {pagetype, templateLink, compareLink}) else text = text .. message('sandbox-notice-blurb', {pagetype, templateLink}) end -- Get the test cases page blurb if the page exists. This is something like -- "See also the companion subpage for [[Template:Foo/testcases|test cases]]." local testcasesTitle = env.testcasesTitle if testcasesTitle and testcasesTitle.exists then if testcasesTitle.namespace == mw.site.namespaces.Module.id then local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display') local testcasesRunLinkDisplay = message('sandbox-notice-testcases-run-link-display') local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay) local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay) text = text .. '<br />' .. message('sandbox-notice-testcases-run-blurb', {testcasesLink, testcasesRunLink}) else local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display') local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay) text = text .. '<br />' .. message('sandbox-notice-testcases-blurb', {testcasesLink}) end end -- Add the sandbox to the sandbox category. text = text .. makeCategoryLink(message('sandbox-category')) omargs.text = text local ret = '<div style="clear: both;"></div>' ret = ret .. messageBox.main('ombox', omargs) return ret end -- function p.protectionTemplate(env) -- Generates the padlock icon in the top right. -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- Messages: -- 'protection-template' --> 'pp-template' -- 'protection-template-args' --> {docusage = 'yes'} -- local protectionLevels, mProtectionBanner -- local title = env.title -- protectionLevels = env.protectionLevels -- if not protectionLevels then -- return nil -- end -- local editProt = protectionLevels.edit and protectionLevels.edit[1] -- local moveProt = protectionLevels.move and protectionLevels.move[1] -- if editProt then -- The page is edit-protected. -- mProtectionBanner = require('Module:Protection banner') -- local reason = message('protection-reason-edit') -- return mProtectionBanner._main{reason, small = true} -- elseif moveProt and moveProt ~= 'autoconfirmed' then -- The page is move-protected but not edit-protected. Exclude move -- protection with the level "autoconfirmed", as this is equivalent to -- no move protection at all. -- mProtectionBanner = require('Module:Protection banner') -- return mProtectionBanner._main{action = 'move', small = true} -- else -- return nil -- end -- end ---------------------------------------------------------------------------- -- Start box ---------------------------------------------------------------------------- p.startBox = makeInvokeFunc('_startBox') function p._startBox(args, env) --[[ -- This function generates the start box. -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- -- The actual work is done by p.makeStartBoxLinksData and p.renderStartBoxLinks which make -- the [view] [edit] [history] [purge] links, and by p.makeStartBoxData and p.renderStartBox -- which generate the box HTML. --]] env = env or p.getEnvironment(args) local links local content = args.content if not content then -- No need to include the links if the documentation is on the template page itself. local linksData = p.makeStartBoxLinksData(args, env) if linksData then links = p.renderStartBoxLinks(linksData) end end -- Generate the start box html. local data = p.makeStartBoxData(args, env, links) if data then return p.renderStartBox(data) else -- User specified no heading. return nil end end function p.makeStartBoxLinksData(args, env) --[[ -- Does initial processing of data to make the [view] [edit] [history] [purge] links. -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- -- Messages: -- 'view-link-display' --> 'view' -- 'edit-link-display' --> 'edit' -- 'history-link-display' --> 'history' -- 'purge-link-display' --> 'purge' -- 'file-docpage-preload' --> 'Template:Documentation/preload-filespace' -- 'module-preload' --> 'Template:Documentation/preload-module-doc' -- 'docpage-preload' --> 'Template:Documentation/preload' -- 'create-link-display' --> 'create' --]] local subjectSpace = env.subjectSpace local title = env.title local docTitle = env.docTitle if not title or not docTitle then return nil end local data = {} data.title = title data.docTitle = docTitle -- View, display, edit, and purge links if /doc exists. data.viewLinkDisplay = message('view-link-display') data.editLinkDisplay = message('edit-link-display') data.historyLinkDisplay = message('history-link-display') data.purgeLinkDisplay = message('purge-link-display') -- Create link if /doc doesn't exist. local preload = args.preload if not preload then if subjectSpace == 6 then -- File namespace preload = message('file-docpage-preload') elseif subjectSpace == 828 then -- Module namespace preload = message('module-preload') else preload = message('docpage-preload') end end data.preload = preload data.createLinkDisplay = message('create-link-display') return data end function p.renderStartBoxLinks(data) --[[ -- Generates the [view][edit][history][purge] or [create] links from the data table. -- @data - a table of data generated by p.makeStartBoxLinksData --]] local function escapeBrackets(s) -- Escapes square brackets with HTML entities. s = s:gsub('%[', '&#91;') -- Replace square brackets with HTML entities. s = s:gsub('%]', '&#93;') return s end local ret local docTitle = data.docTitle local title = data.title if docTitle.exists then local viewLink = makeWikilink(docTitle.prefixedText, data.viewLinkDisplay) local editLink = makeUrlLink(docTitle:fullUrl{action = 'edit'}, data.editLinkDisplay) local historyLink = makeUrlLink(docTitle:fullUrl{action = 'history'}, data.historyLinkDisplay) local purgeLink = makeUrlLink(title:fullUrl{action = 'purge'}, data.purgeLinkDisplay) ret = '[%s] [%s] [%s] [%s]' ret = escapeBrackets(ret) ret = mw.ustring.format(ret, viewLink, editLink, historyLink, purgeLink) else local createLink = makeUrlLink(docTitle:fullUrl{action = 'edit', preload = data.preload}, data.createLinkDisplay) ret = '[%s]' ret = escapeBrackets(ret) ret = mw.ustring.format(ret, createLink) end return ret end function p.makeStartBoxData(args, env, links) --[=[ -- Does initial processing of data to pass to the start-box render function, p.renderStartBox. -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- @links - a string containing the [view][edit][history][purge] links - could be nil if there's an error. -- -- Messages: -- 'documentation-icon-wikitext' --> '[[File:Test Template Info-Icon - Version (2).svg|50px|link=|alt=]]' -- 'template-namespace-heading' --> 'Template documentation' -- 'module-namespace-heading' --> 'Module documentation' -- 'file-namespace-heading' --> 'Summary' -- 'other-namespaces-heading' --> 'Documentation' -- 'start-box-linkclasses' --> 'mw-editsection-like plainlinks' -- 'start-box-link-id' --> 'doc_editlinks' -- 'testcases-create-link-display' --> 'create' --]=] local subjectSpace = env.subjectSpace if not subjectSpace then -- Default to an "other namespaces" namespace, so that we get at least some output -- if an error occurs. subjectSpace = 2 end local data = {} -- Heading local heading = args.heading -- Blank values are not removed. if heading == '' then -- Don't display the start box if the heading arg is defined but blank. return nil end if heading then data.heading = heading elseif subjectSpace == 10 then -- Template namespace data.heading = message('documentation-icon-wikitext') .. ' ' .. message('template-namespace-heading') elseif subjectSpace == 828 then -- Module namespace data.heading = message('documentation-icon-wikitext') .. ' ' .. message('module-namespace-heading') elseif subjectSpace == 6 then -- File namespace data.heading = message('file-namespace-heading') else data.heading = message('other-namespaces-heading') end -- Heading CSS local headingStyle = args['heading-style'] if headingStyle then data.headingStyleText = headingStyle elseif subjectSpace == 10 then -- We are in the template or template talk namespaces. data.headingFontWeight = 'bold' data.headingFontSize = '125%' else data.headingFontSize = '150%' end -- Data for the [view][edit][history][purge] or [create] links. if links then data.linksClass = message('start-box-linkclasses') data.linksId = message('start-box-link-id') data.links = links end return data end function p.renderStartBox(data) -- Renders the start box html. -- @data - a table of data generated by p.makeStartBoxData. local sbox = mw.html.create('div') sbox :css('padding-bottom', '3px') :css('border-bottom', '1px solid #aaa') :css('margin-bottom', '1ex') :newline() :tag('span') :cssText(data.headingStyleText) :css('font-weight', data.headingFontWeight) :css('font-size', data.headingFontSize) :wikitext(data.heading) local links = data.links if links then sbox:tag('span') :addClass(data.linksClass) :attr('id', data.linksId) :wikitext(links) end return tostring(sbox) end ---------------------------------------------------------------------------- -- Documentation content ---------------------------------------------------------------------------- p.content = makeInvokeFunc('_content') function p._content(args, env) -- Displays the documentation contents -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment env = env or p.getEnvironment(args) local docTitle = env.docTitle local content = args.content if not content and docTitle and docTitle.exists then content = args._content or mw.getCurrentFrame():expandTemplate{title = docTitle.prefixedText} end -- The line breaks below are necessary so that "=== Headings ===" at the start and end -- of docs are interpreted correctly. return '\n' .. (content or '') .. '\n' end p.contentTitle = makeInvokeFunc('_contentTitle') function p._contentTitle(args, env) env = env or p.getEnvironment(args) local docTitle = env.docTitle if not args.content and docTitle and docTitle.exists then return docTitle.prefixedText else return '' end end ---------------------------------------------------------------------------- -- End box ---------------------------------------------------------------------------- p.endBox = makeInvokeFunc('_endBox') function p._endBox(args, env) --[=[ -- This function generates the end box (also known as the link box). -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- -- Messages: -- 'fmbox-id' --> 'documentation-meta-data' -- 'fmbox-style' --> 'background-color: #ecfcf4' -- 'fmbox-textstyle' --> 'font-style: italic' -- -- The HTML is generated by the {{fmbox}} template, courtesy of [[Module:Message box]]. --]=] -- Get environment data. env = env or p.getEnvironment(args) local subjectSpace = env.subjectSpace local docTitle = env.docTitle if not subjectSpace or not docTitle then return nil end -- Check whether we should output the end box at all. Add the end -- box by default if the documentation exists or if we are in the -- user, module or template namespaces. local linkBox = args['link box'] if linkBox == 'off' or not ( docTitle.exists or subjectSpace == 2 or subjectSpace == 828 or subjectSpace == 10 ) then return nil end -- Assemble the arguments for {{fmbox}}. local fmargs = {} fmargs.id = message('fmbox-id') -- Sets 'documentation-meta-data' fmargs.image = 'none' fmargs.style = message('fmbox-style') -- Sets 'background-color: #ecfcf4' fmargs.textstyle = message('fmbox-textstyle') -- 'font-style: italic;' -- Assemble the fmbox text field. local text = '' if linkBox then text = text .. linkBox else text = text .. (p.makeDocPageBlurb(args, env) or '') -- "This documentation is transcluded from [[Foo]]." if subjectSpace == 2 or subjectSpace == 10 or subjectSpace == 828 then -- We are in the user, template or module namespaces. -- Add sandbox and testcases links. -- "Editors can experiment in this template's sandbox and testcases pages." text = text .. (p.makeExperimentBlurb(args, env) or '') text = text .. '<br />' if not args.content and not args[1] then -- "Please add categories to the /doc subpage." -- Don't show this message with inline docs or with an explicitly specified doc page, -- as then it is unclear where to add the categories. text = text .. (p.makeCategoriesBlurb(args, env) or '') end text = text .. ' ' .. (p.makeSubpagesBlurb(args, env) or '') --"Subpages of this template" local printBlurb = p.makePrintBlurb(args, env) -- Two-line blurb about print versions of templates. if printBlurb then text = text .. '<br />' .. printBlurb end end end fmargs.text = text return messageBox.main('fmbox', fmargs) end function p.makeDocPageBlurb(args, env) --[=[ -- Makes the blurb "This documentation is transcluded from [[Template:Foo]] (edit, history)". -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- -- Messages: -- 'edit-link-display' --> 'edit' -- 'history-link-display' --> 'history' -- 'transcluded-from-blurb' --> -- 'The above [[Wikipedia:Template documentation|documentation]] -- is [[Wikipedia:Transclusion|transcluded]] from $1.' -- 'module-preload' --> 'Template:Documentation/preload-module-doc' -- 'create-link-display' --> 'create' -- 'create-module-doc-blurb' --> -- 'You might want to $1 a documentation page for this [[Wikipedia:Lua|Scribunto module]].' --]=] local docTitle = env.docTitle if not docTitle then return nil end local ret if docTitle.exists then -- /doc exists; link to it. local docLink = makeWikilink(docTitle.prefixedText) local editUrl = docTitle:fullUrl{action = 'edit'} local editDisplay = message('edit-link-display') local editLink = makeUrlLink(editUrl, editDisplay) local historyUrl = docTitle:fullUrl{action = 'history'} local historyDisplay = message('history-link-display') local historyLink = makeUrlLink(historyUrl, historyDisplay) ret = message('transcluded-from-blurb', {docLink}) .. ' ' .. makeToolbar(editLink, historyLink) .. '<br />' elseif env.subjectSpace == 828 then -- /doc does not exist; ask to create it. local createUrl = docTitle:fullUrl{action = 'edit', preload = message('module-preload')} local createDisplay = message('create-link-display') local createLink = makeUrlLink(createUrl, createDisplay) ret = message('create-module-doc-blurb', {createLink}) .. '<br />' end return ret end function p.makeExperimentBlurb(args, env) --[[ -- Renders the text "Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages." -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- -- Messages: -- 'sandbox-link-display' --> 'sandbox' -- 'sandbox-edit-link-display' --> 'edit' -- 'compare-link-display' --> 'diff' -- 'module-sandbox-preload' --> 'Template:Documentation/preload-module-sandbox' -- 'template-sandbox-preload' --> 'Template:Documentation/preload-sandbox' -- 'sandbox-create-link-display' --> 'create' -- 'mirror-edit-summary' --> 'Create sandbox version of $1' -- 'mirror-link-display' --> 'mirror' -- 'mirror-link-preload' --> 'Template:Documentation/mirror' -- 'sandbox-link-display' --> 'sandbox' -- 'testcases-link-display' --> 'testcases' -- 'testcases-edit-link-display'--> 'edit' -- 'template-sandbox-preload' --> 'Template:Documentation/preload-sandbox' -- 'testcases-create-link-display' --> 'create' -- 'testcases-link-display' --> 'testcases' -- 'testcases-edit-link-display' --> 'edit' -- 'module-testcases-preload' --> 'Template:Documentation/preload-module-testcases' -- 'template-testcases-preload' --> 'Template:Documentation/preload-testcases' -- 'experiment-blurb-module' --> 'Editors can experiment in this module's $1 and $2 pages.' -- 'experiment-blurb-template' --> 'Editors can experiment in this template's $1 and $2 pages.' --]] local subjectSpace = env.subjectSpace local templateTitle = env.templateTitle local sandboxTitle = env.sandboxTitle local testcasesTitle = env.testcasesTitle local templatePage = templateTitle.prefixedText if not subjectSpace or not templateTitle or not sandboxTitle or not testcasesTitle then return nil end -- Make links. local sandboxLinks, testcasesLinks if sandboxTitle.exists then local sandboxPage = sandboxTitle.prefixedText local sandboxDisplay = message('sandbox-link-display') local sandboxLink = makeWikilink(sandboxPage, sandboxDisplay) local sandboxEditUrl = sandboxTitle:fullUrl{action = 'edit'} local sandboxEditDisplay = message('sandbox-edit-link-display') local sandboxEditLink = makeUrlLink(sandboxEditUrl, sandboxEditDisplay) local compareUrl = env.compareUrl local compareLink if compareUrl then local compareDisplay = message('compare-link-display') compareLink = makeUrlLink(compareUrl, compareDisplay) end sandboxLinks = sandboxLink .. ' ' .. makeToolbar(sandboxEditLink, compareLink) else local sandboxPreload if subjectSpace == 828 then sandboxPreload = message('module-sandbox-preload') else sandboxPreload = message('template-sandbox-preload') end local sandboxCreateUrl = sandboxTitle:fullUrl{action = 'edit', preload = sandboxPreload} local sandboxCreateDisplay = message('sandbox-create-link-display') local sandboxCreateLink = makeUrlLink(sandboxCreateUrl, sandboxCreateDisplay) local mirrorSummary = message('mirror-edit-summary', {makeWikilink(templatePage)}) local mirrorPreload = message('mirror-link-preload') local mirrorUrl = sandboxTitle:fullUrl{action = 'edit', preload = mirrorPreload, summary = mirrorSummary} if subjectSpace == 828 then mirrorUrl = sandboxTitle:fullUrl{action = 'edit', preload = templateTitle.prefixedText, summary = mirrorSummary} end local mirrorDisplay = message('mirror-link-display') local mirrorLink = makeUrlLink(mirrorUrl, mirrorDisplay) sandboxLinks = message('sandbox-link-display') .. ' ' .. makeToolbar(sandboxCreateLink, mirrorLink) end if testcasesTitle.exists then local testcasesPage = testcasesTitle.prefixedText local testcasesDisplay = message('testcases-link-display') local testcasesLink = makeWikilink(testcasesPage, testcasesDisplay) local testcasesEditUrl = testcasesTitle:fullUrl{action = 'edit'} local testcasesEditDisplay = message('testcases-edit-link-display') local testcasesEditLink = makeUrlLink(testcasesEditUrl, testcasesEditDisplay) -- for Modules, add testcases run link if exists if subjectSpace == 828 and testcasesTitle.talkPageTitle and testcasesTitle.talkPageTitle.exists then local testcasesRunLinkDisplay = message('testcases-run-link-display') local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay) testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink, testcasesRunLink) else testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink) end else local testcasesPreload if subjectSpace == 828 then testcasesPreload = message('module-testcases-preload') else testcasesPreload = message('template-testcases-preload') end local testcasesCreateUrl = testcasesTitle:fullUrl{action = 'edit', preload = testcasesPreload} local testcasesCreateDisplay = message('testcases-create-link-display') local testcasesCreateLink = makeUrlLink(testcasesCreateUrl, testcasesCreateDisplay) testcasesLinks = message('testcases-link-display') .. ' ' .. makeToolbar(testcasesCreateLink) end local messageName if subjectSpace == 828 then messageName = 'experiment-blurb-module' else messageName = 'experiment-blurb-template' end return message(messageName, {sandboxLinks, testcasesLinks}) end function p.makeCategoriesBlurb(args, env) --[[ -- Generates the text "Please add categories to the /doc subpage." -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- Messages: -- 'doc-link-display' --> '/doc' -- 'add-categories-blurb' --> 'Please add categories to the $1 subpage.' --]] local docTitle = env.docTitle if not docTitle then return nil end local docPathLink = makeWikilink(docTitle.prefixedText, message('doc-link-display')) return message('add-categories-blurb', {docPathLink}) end function p.makeSubpagesBlurb(args, env) --[[ -- Generates the "Subpages of this template" link. -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- Messages: -- 'template-pagetype' --> 'template' -- 'module-pagetype' --> 'module' -- 'default-pagetype' --> 'page' -- 'subpages-link-display' --> 'Subpages of this $1' --]] local subjectSpace = env.subjectSpace local templateTitle = env.templateTitle if not subjectSpace or not templateTitle then return nil end local pagetype if subjectSpace == 10 then pagetype = message('template-pagetype') elseif subjectSpace == 828 then pagetype = message('module-pagetype') else pagetype = message('default-pagetype') end local subpagesLink = makeWikilink( 'Special:PrefixIndex/' .. templateTitle.prefixedText .. '/', message('subpages-link-display', {pagetype}) ) return message('subpages-blurb', {subpagesLink}) end function p.makePrintBlurb(args, env) --[=[ -- Generates the blurb displayed when there is a print version of the template available. -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- -- Messages: -- 'print-link-display' --> '/Print' -- 'print-blurb' --> 'A [[Help:Books/for experts#Improving the book layout|print version]]' -- .. ' of this template exists at $1.' -- .. ' If you make a change to this template, please update the print version as well.' -- 'display-print-category' --> true -- 'print-category' --> 'Templates with print versions' --]=] local printTitle = env.printTitle if not printTitle then return nil end local ret if printTitle.exists then local printLink = makeWikilink(printTitle.prefixedText, message('print-link-display')) ret = message('print-blurb', {printLink}) local displayPrintCategory = message('display-print-category', nil, 'boolean') if displayPrintCategory then ret = ret .. makeCategoryLink(message('print-category')) end end return ret end ---------------------------------------------------------------------------- -- Tracking categories ---------------------------------------------------------------------------- function p.addTrackingCategories(env) --[[ -- Check if {{documentation}} is transcluded on a /doc or /testcases page. -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- Messages: -- 'display-strange-usage-category' --> true -- 'doc-subpage' --> 'doc' -- 'testcases-subpage' --> 'testcases' -- 'strange-usage-category' --> 'Wikipedia pages with strange ((documentation)) usage' -- -- /testcases pages in the module namespace are not categorised, as they may have -- {{documentation}} transcluded automatically. --]] local title = env.title local subjectSpace = env.subjectSpace if not title or not subjectSpace then return nil end local subpage = title.subpageText local ret = '' if message('display-strange-usage-category', nil, 'boolean') and ( subpage == message('doc-subpage') or subjectSpace ~= 828 and subpage == message('testcases-subpage') ) then ret = ret .. makeCategoryLink(message('strange-usage-category')) end return ret end return p 5526f3e983324ad73f5b8865471ba81108a2198c モジュール:Documentation/config 828 35 74 73 2019-06-23T17:10:34Z Ochaochaocha3 1 1版 をインポートしました Scribunto text/plain ---------------------------------------------------------------------------------------------------- -- -- Configuration for Module:Documentation -- -- Here you can set the values of the parameters and messages used in Module:Documentation to -- localise it to your wiki and your language. Unless specified otherwise, values given here -- should be string values. ---------------------------------------------------------------------------------------------------- local cfg = {} -- Do not edit this line. ---------------------------------------------------------------------------------------------------- -- Protection template configuration ---------------------------------------------------------------------------------------------------- -- cfg['protection-reason-edit'] -- The protection reason for edit-protected templates to pass to -- [[Module:Protection banner]]. -- cfg['protection-reason-edit'] = 'template' --[[ ---------------------------------------------------------------------------------------------------- -- Sandbox notice configuration -- -- On sandbox pages the module can display a template notifying users that the current page is a -- sandbox, and the location of test cases pages, etc. The module decides whether the page is a -- sandbox or not based on the value of cfg['sandbox-subpage']. The following settings configure the -- messages that the notices contains. ---------------------------------------------------------------------------------------------------- --]] -- cfg['sandbox-notice-image'] -- The image displayed in the sandbox notice. cfg['sandbox-notice-image'] = '[[Image:Sandbox.svg|50px|alt=|link=]]' --[[ -- cfg['sandbox-notice-pagetype-template'] -- cfg['sandbox-notice-pagetype-module'] -- cfg['sandbox-notice-pagetype-other'] -- The page type of the sandbox page. The message that is displayed depends on the current subject -- namespace. This message is used in either cfg['sandbox-notice-blurb'] or -- cfg['sandbox-notice-diff-blurb']. --]] cfg['sandbox-notice-pagetype-template'] = '[[Wikipedia:テンプレートのサンドボックスとテストケース|テンプレート・サンドボックス]]ページ' cfg['sandbox-notice-pagetype-module'] = '[[Wikipedia:テンプレートのサンドボックスとテストケース|モジュール・サンドボックス]]ページ' cfg['sandbox-notice-pagetype-other'] = 'サンドボックス・ページ' --[[ -- cfg['sandbox-notice-blurb'] -- cfg['sandbox-notice-diff-blurb'] -- cfg['sandbox-notice-diff-display'] -- Either cfg['sandbox-notice-blurb'] or cfg['sandbox-notice-diff-blurb'] is the opening sentence -- of the sandbox notice. The latter has a diff link, but the former does not. $1 is the page -- type, which is either cfg['sandbox-notice-pagetype-template'], -- cfg['sandbox-notice-pagetype-module'] or cfg['sandbox-notice-pagetype-other'] depending what -- namespace we are in. $2 is a link to the main template page, and $3 is a diff link between -- the sandbox and the main template. The display value of the diff link is set by -- cfg['sandbox-notice-compare-link-display']. --]] cfg['sandbox-notice-blurb'] = 'これは$2の$1です。' cfg['sandbox-notice-diff-blurb'] = 'これは$2 ($3)の$1です。' cfg['sandbox-notice-compare-link-display'] = '差分' --[[ -- cfg['sandbox-notice-testcases-blurb'] -- cfg['sandbox-notice-testcases-link-display'] -- cfg['sandbox-notice-testcases-run-blurb'] -- cfg['sandbox-notice-testcases-run-link-display'] -- cfg['sandbox-notice-testcases-blurb'] is a sentence notifying the user that there is a test cases page -- corresponding to this sandbox that they can edit. $1 is a link to the test cases page. -- cfg['sandbox-notice-testcases-link-display'] is the display value for that link. -- cfg['sandbox-notice-testcases-run-blurb'] is a sentence notifying the user that there is a test cases page -- corresponding to this sandbox that they can edit, along with a link to run it. $1 is a link to the test -- cases page, and $2 is a link to the page to run it. -- cfg['sandbox-notice-testcases-run-link-display'] is the display value for the link to run the test -- cases. --]] cfg['sandbox-notice-testcases-blurb'] = '対応する$1・サブページもご確認ください。' cfg['sandbox-notice-testcases-link-display'] = 'テストケース' cfg['sandbox-notice-testcases-run-blurb'] = '対応する$1・サブページ ($2) もご確認ください。' cfg['sandbox-notice-testcases-run-link-display'] = '実行' -- cfg['sandbox-category'] -- A category to add to all template sandboxes. cfg['sandbox-category'] = 'テンプレート・サンドボックス' ---------------------------------------------------------------------------------------------------- -- Start box configuration ---------------------------------------------------------------------------------------------------- -- cfg['documentation-icon-wikitext'] -- The wikitext for the icon shown at the top of the template. cfg['documentation-icon-wikitext'] = '[[File:Test Template Info-Icon - Version (2).svg|50px|link=|alt=]]' -- cfg['template-namespace-heading'] -- The heading shown in the template namespace. cfg['template-namespace-heading'] = 'テンプレートの解説' -- cfg['module-namespace-heading'] -- The heading shown in the module namespace. cfg['module-namespace-heading'] = 'モジュールの解説' -- cfg['file-namespace-heading'] -- The heading shown in the file namespace. cfg['file-namespace-heading'] = '要約' -- cfg['other-namespaces-heading'] -- The heading shown in other namespaces. cfg['other-namespaces-heading'] = '解説' -- cfg['view-link-display'] -- The text to display for "view" links. cfg['view-link-display'] = '表示' -- cfg['edit-link-display'] -- The text to display for "edit" links. cfg['edit-link-display'] = '編集' -- cfg['history-link-display'] -- The text to display for "history" links. cfg['history-link-display'] = '履歴' -- cfg['purge-link-display'] -- The text to display for "purge" links. cfg['purge-link-display'] = 'キャッシュを破棄' -- cfg['create-link-display'] -- The text to display for "create" links. cfg['create-link-display'] = '作成' ---------------------------------------------------------------------------------------------------- -- Link box (end box) configuration ---------------------------------------------------------------------------------------------------- -- cfg['transcluded-from-blurb'] -- Notice displayed when the docs are transcluded from another page. $1 is a wikilink to that page. cfg['transcluded-from-blurb'] = 'この[[Help:テンプレートの説明文|解説]]は、$1から[[Help:テンプレート#テンプレートとは|呼び出されて]]います。' --[[ -- cfg['create-module-doc-blurb'] -- Notice displayed in the module namespace when the documentation subpage does not exist. -- $1 is a link to create the documentation page with the preload cfg['module-preload'] and the -- display cfg['create-link-display']. --]] cfg['create-module-doc-blurb'] = 'この[[Wikipedia:Lua|Scribuntoモジュール]]の解説ページを$1することができます。' ---------------------------------------------------------------------------------------------------- -- Experiment blurb configuration ---------------------------------------------------------------------------------------------------- --[[ -- cfg['experiment-blurb-template'] -- cfg['experiment-blurb-module'] -- The experiment blurb is the text inviting editors to experiment in sandbox and test cases pages. -- It is only shown in the template and module namespaces. With the default English settings, it -- might look like this: -- -- Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages. -- -- In this example, "sandbox", "edit", "diff", "testcases", and "edit" would all be links. -- -- There are two versions, cfg['experiment-blurb-template'] and cfg['experiment-blurb-module'], depending -- on what namespace we are in. -- -- Parameters: -- -- $1 is a link to the sandbox page. If the sandbox exists, it is in the following format: -- -- cfg['sandbox-link-display'] (cfg['sandbox-edit-link-display'] | cfg['compare-link-display']) -- -- If the sandbox doesn't exist, it is in the format: -- -- cfg['sandbox-link-display'] (cfg['sandbox-create-link-display'] | cfg['mirror-link-display']) -- -- The link for cfg['sandbox-create-link-display'] link preloads the page with cfg['template-sandbox-preload'] -- or cfg['module-sandbox-preload'], depending on the current namespace. The link for cfg['mirror-link-display'] -- loads a default edit summary of cfg['mirror-edit-summary']. -- -- $2 is a link to the test cases page. If the test cases page exists, it is in the following format: -- -- cfg['testcases-link-display'] (cfg['testcases-edit-link-display'] | cfg['testcases-run-link-display']) -- -- If the test cases page doesn't exist, it is in the format: -- -- cfg['testcases-link-display'] (cfg['testcases-create-link-display']) -- -- If the test cases page doesn't exist, the link for cfg['testcases-create-link-display'] preloads the -- page with cfg['template-testcases-preload'] or cfg['module-testcases-preload'], depending on the current -- namespace. --]] cfg['experiment-blurb-template'] = "編集者は、このテンプレートを$1と$2で試すことができます。([[Wikipedia:テンプレートのサンドボックスとテストケース|解説]])" cfg['experiment-blurb-module'] = "編集者は、このモジュールを$1と$2で試すことができます。([[Wikipedia:テンプレートのサンドボックスとテストケース|解説]])" ---------------------------------------------------------------------------------------------------- -- Sandbox link configuration ---------------------------------------------------------------------------------------------------- -- cfg['sandbox-subpage'] -- The name of the template subpage typically used for sandboxes. cfg['sandbox-subpage'] = 'sandbox' -- cfg['template-sandbox-preload'] -- Preload file for template sandbox pages. cfg['template-sandbox-preload'] = 'Template:Documentation/preload-sandbox' -- cfg['module-sandbox-preload'] -- Preload file for Lua module sandbox pages. cfg['module-sandbox-preload'] = 'Template:Documentation/preload-module-sandbox' -- cfg['sandbox-link-display'] -- The text to display for "sandbox" links. cfg['sandbox-link-display'] = 'サンドボックス' -- cfg['sandbox-edit-link-display'] -- The text to display for sandbox "edit" links. cfg['sandbox-edit-link-display'] = '編集' -- cfg['sandbox-create-link-display'] -- The text to display for sandbox "create" links. cfg['sandbox-create-link-display'] = '作成' -- cfg['compare-link-display'] -- The text to display for "compare" links. cfg['compare-link-display'] = '差分' -- cfg['mirror-edit-summary'] -- The default edit summary to use when a user clicks the "mirror" link. $1 is a wikilink to the -- template page. cfg['mirror-edit-summary'] = '$1のサンドボックスバージョンを作成' -- cfg['mirror-link-display'] -- The text to display for "mirror" links. cfg['mirror-link-display'] = '複製' -- cfg['mirror-link-preload'] -- The page to preload when a user clicks the "mirror" link. cfg['mirror-link-preload'] = 'Template:Documentation/mirror' ---------------------------------------------------------------------------------------------------- -- Test cases link configuration ---------------------------------------------------------------------------------------------------- -- cfg['testcases-subpage'] -- The name of the template subpage typically used for test cases. cfg['testcases-subpage'] = 'testcases' -- cfg['template-testcases-preload'] -- Preload file for template test cases pages. cfg['template-testcases-preload'] = 'Template:Documentation/preload-testcases' -- cfg['module-testcases-preload'] -- Preload file for Lua module test cases pages. cfg['module-testcases-preload'] = 'Template:Documentation/preload-module-testcases' -- cfg['testcases-link-display'] -- The text to display for "testcases" links. cfg['testcases-link-display'] = 'テストケース' -- cfg['testcases-edit-link-display'] -- The text to display for test cases "edit" links. cfg['testcases-edit-link-display'] = '編集' -- cfg['testcases-run-link-display'] -- The text to display for test cases "run" links. cfg['testcases-run-link-display'] = '作動' -- cfg['testcases-create-link-display'] -- The text to display for test cases "create" links. cfg['testcases-create-link-display'] = '作成' ---------------------------------------------------------------------------------------------------- -- Add categories blurb configuration ---------------------------------------------------------------------------------------------------- --[[ -- cfg['add-categories-blurb'] -- Text to direct users to add categories to the /doc subpage. Not used if the "content" or -- "docname fed" arguments are set, as then it is not clear where to add the categories. $1 is a -- link to the /doc subpage with a display value of cfg['doc-link-display']. --]] cfg['add-categories-blurb'] = '$1のサブページにカテゴリを追加してください。' -- cfg['doc-link-display'] -- The text to display when linking to the /doc subpage. cfg['doc-link-display'] = '/doc' ---------------------------------------------------------------------------------------------------- -- Subpages link configuration ---------------------------------------------------------------------------------------------------- --[[ -- cfg['subpages-blurb'] -- The "Subpages of this template" blurb. $1 is a link to the main template's subpages with a -- display value of cfg['subpages-link-display']. In the English version this blurb is simply -- the link followed by a period, and the link display provides the actual text. --]] cfg['subpages-blurb'] = '$1' --[[ -- cfg['subpages-link-display'] -- The text to display for the "subpages of this page" link. $1 is cfg['template-pagetype'], -- cfg['module-pagetype'] or cfg['default-pagetype'], depending on whether the current page is in -- the template namespace, the module namespace, or another namespace. --]] cfg['subpages-link-display'] = 'この$1のサブページ一覧。' -- cfg['template-pagetype'] -- The pagetype to display for template pages. cfg['template-pagetype'] = 'テンプレート' -- cfg['module-pagetype'] -- The pagetype to display for Lua module pages. cfg['module-pagetype'] = 'モジュール' -- cfg['default-pagetype'] -- The pagetype to display for pages other than templates or Lua modules. cfg['default-pagetype'] = 'ページ' ---------------------------------------------------------------------------------------------------- -- Doc link configuration ---------------------------------------------------------------------------------------------------- -- cfg['doc-subpage'] -- The name of the subpage typically used for documentation pages. cfg['doc-subpage'] = 'doc' -- cfg['file-docpage-preload'] -- Preload file for documentation page in the file namespace. cfg['file-docpage-preload'] = 'Template:Documentation/preload-filespace' -- cfg['docpage-preload'] -- Preload file for template documentation pages in all namespaces. cfg['docpage-preload'] = 'Template:Documentation/preload' -- cfg['module-preload'] -- Preload file for Lua module documentation pages. cfg['module-preload'] = 'Template:Documentation/preload-module-doc' ---------------------------------------------------------------------------------------------------- -- Print version configuration ---------------------------------------------------------------------------------------------------- -- cfg['print-subpage'] -- The name of the template subpage used for print versions. cfg['print-subpage'] = 'Print' -- cfg['print-link-display'] -- The text to display when linking to the /Print subpage. cfg['print-link-display'] = '/Print' -- cfg['print-blurb'] -- Text to display if a /Print subpage exists. $1 is a link to the subpage with a display value of cfg['print-link-display']. cfg['print-blurb'] = '$1にこのテンプレートはの[[Help:Books/for experts#Improving the book layout|印刷バージョンがあります]]。' .. 'もしこのテンプレートを更新した時は、印刷バージョンも更新してください。' -- cfg['display-print-category'] -- Set to true to enable output of cfg['print-category'] if a /Print subpage exists. -- This should be a boolean value (either true or false). cfg['display-print-category'] = true -- cfg['print-category'] -- Category to output if cfg['display-print-category'] is set to true, and a /Print subpage exists. cfg['print-category'] = '' ---------------------------------------------------------------------------------------------------- -- HTML and CSS configuration ---------------------------------------------------------------------------------------------------- -- cfg['main-div-id'] -- The "id" attribute of the main HTML "div" tag. cfg['main-div-id'] = 'template-documentation' -- cfg['main-div-classes'] -- The CSS classes added to the main HTML "div" tag. cfg['main-div-classes'] = 'template-documentation iezoomfix' -- cfg['start-box-linkclasses'] -- The CSS classes used for the [view][edit][history] or [create] links in the start box. cfg['start-box-linkclasses'] = 'mw-editsection-like plainlinks' -- cfg['start-box-link-id'] -- The HTML "id" attribute for the links in the start box. cfg['start-box-link-id'] = 'doc_editlinks' ---------------------------------------------------------------------------------------------------- -- {{fmbox}} template configuration ---------------------------------------------------------------------------------------------------- -- cfg['fmbox-id'] -- The id sent to the "id" parameter of the {{fmbox}} template. cfg['fmbox-id'] = 'documentation-meta-data' -- cfg['fmbox-style'] -- The value sent to the style parameter of {{fmbox}}. cfg['fmbox-style'] = 'background-color: #ecfcf4' -- cfg['fmbox-textstyle'] -- The value sent to the "textstyle parameter of {{fmbox}}. cfg['fmbox-textstyle'] = 'font-style: italic' ---------------------------------------------------------------------------------------------------- -- Tracking category configuration ---------------------------------------------------------------------------------------------------- -- cfg['display-strange-usage-category'] -- Set to true to enable output of cfg['strange-usage-category'] if the module is used on a /doc subpage -- or a /testcases subpage. This should be a boolean value (either true or false). cfg['display-strange-usage-category'] = true -- cfg['strange-usage-category'] -- Category to output if cfg['display-strange-usage-category'] is set to true and the module is used on a -- /doc subpage or a /testcases subpage. cfg['strange-usage-category'] = '((documentation))の異常な使用があるページ' --[[ ---------------------------------------------------------------------------------------------------- -- End configuration -- -- Don't edit anything below this line. ---------------------------------------------------------------------------------------------------- --]] return cfg 063e3994fdbad524d528acb6d213f6a9cc3f7580 モジュール:Infobox/former 828 36 76 75 2019-06-23T17:10:34Z Ochaochaocha3 1 1版 をインポートしました Scribunto text/plain local p = {} function p.main(frame) local args = require('Module:Arguments').getArgs(frame, {parentOnly = true}) --引数取得 local child = (args.child == 'yes') local subbox = (args.subbox == 'yes') local h = {subheader = {}, image = {{}}} --ヘッダー部(subheader, image)テーブル local body, sbody = {}, {} --本体部テーブル, ソート済み本体部テーブル local link = args.tnavbar or args.name --(フッター部)テンプレート名 local result = '' --結果格納用 --[[ subheader, image用引数振り分け ]] local function args2tbl(str, k, v) local num = string.match(k, '%d*$') num = (num == '') and 1 or tonumber(num) h[str][num] = h[str][num] or {} if k == str then h[str][1][1] = v elseif string.match(k, str .. '%d+') then h[str][num][1] = v elseif string.find(k, 'style') then if string.match(k, 'style$') then h[str]['style'] = v else h[str][num]['style'] = v end elseif string.find(k, 'rowclass') then if string.match(k, 'rowclass$') then h[str]['rowclass'] = v else h[str][num]['rowclass'] = v end elseif string.match(k, 'class$') then h[str]['class'] = v end end --[[ 引数振り分け ]] for k, v in pairs(args) do --subheader if string.find(k, 'subheader') then args2tbl('subheader', k, v) --image elseif string.find(k, 'image') then args2tbl('image', k, v) elseif string.find(k, 'caption') then if string.match(k, 'caption$') then h['image'][1]['caption'] = '<div style="' .. (args.captionstyle or '') .. '">' .. v .. '</div>' elseif string.match(k, 'caption%d+') then local num = tonumber(string.match(k, '%d*$')) h['image'][num] = h['image'][num] or {} h['image'][num]['caption'] = '<div style="' .. (args.captionstyle or '') .. '">' .. v .. '</div>' end --その他(本体部) elseif string.match(k, '^%D+%d+$') then local str, num = string.match(k, '^(%D+)(%d+)$') num = tonumber(num) if not body[num] then local OddOrEven = (num % 2 ~= 0) and 'odd' or 'even' body[num] = { num, headerstyle = (args.headerstyle or '') .. (args[OddOrEven .. 'headerstyle'] or ''), labelstyle = (args.labelstyle or '') .. (args[OddOrEven .. 'labelstyle'] or ''), datastyle = (args.datastyle or '') .. (args[OddOrEven .. 'datastyle'] or '') } end body[num][str] = (body[num][str] or '') .. v end end --[[ Template:Infobox/row ]] local function row(header, headerstyle, label, labelstyle, data, datastyle, rowstyle, class, rowclass, id, itemprop, rowitemprop, itemtype, rowitemtype, itemref, rowitemref) local result ='' if header then result = '<tr style="' .. (rowstyle or '') ..'"' .. (rowitemtype and (' itemscope itemtype="' .. rowitemtype .. '"') or '') .. ' itemref="' .. (rowitemref or '') .. '"><th scope="col" colspan="2" class="' .. (class or '') .. '" style="text-align:center; ' .. (headerstyle or '') .. '">' .. header .. '</th></tr>' elseif data then result = '<tr class="' .. (rowclass or '') .. '" style="' .. (rowstyle or '') .. '" itemprop="' .. (rowitemprop or '') .. '"' .. (rowitemtype and (' itemscope itemtype="' .. rowitemtype .. '"') or '') .. ' itemref="' .. (rowitemref or '') .. '">' if label then result = result .. '<th scope="row" style="text-align:left; white-space:nowrap; ' .. (labelstyle or '') .. '">' .. label .. '</th><td class="' .. (class or '') .. '" style="' .. (datastyle or '') .. '" itemprop="' .. (itemprop or '') .. '"' .. (itemtype and (' itemscope itemtype="' .. itemtype .. '"') or '') .. ' itemref="' .. (itemref or '') .. '">' else result = result .. '<td colspan="2" class="' .. (class or '') .. '" style="text-align:center; ' .. (datastyle or '') .. '" itemprop="' .. (itemprop or '') .. '"' .. (itemtype and (' itemscope itemtype="' .. rowitemtype .. '"') or '') .. ' itemref="' .. (itemref or '') .. '">' end result = result .. '\n' .. data .. '</td></tr>' end return result end --[[ Template:Infobox ]] --ヘッダー部 if not child then --tableタグ result = '<table class="' .. (subbox and '' or 'infobox ') .. (args.bodyclass or '') .. '" style="' .. (subbox and 'min-width:100%; width:calc(100% + 6px); margin:-3px; ' or 'width:22em; ') .. (args.bodystyle or '') .. '"' .. (args.bodyitemtype and (' itemscope itemtype="' .. args.bodyitemtype .. '"') or '') .. ' itemref="' .. (args.bodyitemref or '') .. '">' if args.title then --captionタグ result = result .. '<caption itemprop="name" class="' .. (args.titleclass or '') .. ' style="' .. (args.titlestyle or '') .. '">' .. args.title .. '</caption>' end if args.above then result = result .. '<tr><th colspan="2" class="' .. (args.aboveclass or '') .. '" style="text-align:center; font-size:125%; font-weight:bold; ' .. (args.abovestyle or '') .. '" itemprop="' .. (args.aboveitemprop or '') .. '"' .. (args.aboveitemtype and (' itemscope itemtype="' .. args.aboveitemtype .. '"') or '') .. ' itemref="' .. (args.aboveitemref or '') .. '">' .. args.above ..'</th></tr>' end else if args.title then result = '<b itemprop="name' .. '"' .. (args.bodyitemtype and (' itemscope itemtype="' .. args.bodyitemtype .. '"') or '') .. ' itemref="' .. (args.bodyitemref or '') .. '">' .. args.title .. '</b>' end end for k, v in pairs(h.subheader) do result = result .. row(nil, nil, nil, nil, v[1], v.style or h.subheader.style, v.rowstyle, h.subheader.class, v.rowclass, nil, nil, nil, nil, nil, nil, nil) end for k, v in pairs(h.image) do result = result .. row(nil, nil, nil, nil, v[1] and (v[1] .. (v.caption or '')), v.style or h.image.style, v.rowstyle, h.image.class, v.rowclass, nil, nil, nil, nil, nil, nil, nil) end --本体部ソート for k, v in pairs(body) do sbody[#sbody + 1] = v end table.sort(sbody, function (a, b) return a[1] < b[1] end ) --本体部 for k, v in ipairs(sbody) do result = result .. row(v.header, v.headerstyle, v.label, v.labelstyle, v.data, v.datastyle, v.rowstyle, v.class, v.rowclass or args.rowclass, v.id, v.itemprop, v.rowitemprop, v.itemtype, v.rowitemtype, v.itemref, v.rowitemref) end --フッター部 if args.below then result = result .. '<tr><td colspan="2" class="' .. (args.belowclass or '') .. '" style="text-align:center; ' .. (args.belowstyle or '') .. '">' .. args.below .. '</td></tr>' end if link then --Template:Transclude link = string.gsub(link, ':?[Tt]emplate:', '') if not string.find(link, ':') then link = 'Template:' .. link end result = result .. '<tr class="noprint"><td colspan=2 style="text-align:right; font-size:85%;">[[' .. link .. '|テンプレートを表示]]</td></tr>' end --tableタグ閉じ if not child then result = result .. '</table>' end --出力 return result end return p 664796a7cacee7fefae945001974b596fb3a82e0 モジュール:InfoboxImage 828 37 78 77 2019-06-23T17:10:34Z Ochaochaocha3 1 1版 をインポートしました Scribunto text/plain -- Inputs: -- image - Can either be a bare filename (with or without the File:/Image: prefix) or a fully formatted image link -- page - page to display for multipage images (DjVu) -- size - size to display the image -- maxsize - maximum size for image -- sizedefault - default size to display the image if size param is blank -- alt - alt text for image -- title - title text for image -- border - set to yes if border -- center - set to yes, if the image has to be centered -- upright - upright image param -- suppressplaceholder - if yes then checks to see if image is a placeholder and suppresses it -- link - page to visit when clicking on image -- Outputs: -- Formatted image. -- More details available at the "Module:InfoboxImage/doc" page local i = {}; local placeholder_image = { "Blue - Replace this image female.svg", "Blue - Replace this image male.svg", "Female no free image yet.png", "Flag of None (square).svg", "Flag of None.svg", "Flag of.svg", "Green - Replace this image female.svg", "Green - Replace this image male.svg", "Image is needed female.svg", "Image is needed male.svg", "Location map of None.svg", "Male no free image yet.png", "Missing flag.png", "No flag.svg", "No free portrait.svg", "No portrait (female).svg", "No portrait (male).svg", "Red - Replace this image female.svg", "Red - Replace this image male.svg", "Replace this image female (blue).svg", "Replace this image female.svg", "Replace this image male (blue).svg", "Replace this image male.svg", "Silver - Replace this image female.svg", "Silver - Replace this image male.svg", "Replace this image.svg", "Cricket no pic.png", "CarersLogo.gif", "Diagram Needed.svg", "Example.jpg", "Image placeholder.png", "No male portrait.svg", "Nocover-upload.png", "NoDVDcover copy.png", "Noribbon.svg", "No portrait-BFD-test.svg", "Placeholder barnstar ribbon.png", "Project Trains no image.png", "Image-request.png", "Sin bandera.svg", "Sin escudo.svg", "Replace this image - temple.png", "Replace this image butterfly.png", "Replace this image.svg", "Replace this image1.svg", "Resolution angle.png", "Image-No portrait-text-BFD-test.svg", "Insert image here.svg", "No image available.png", "NO IMAGE YET square.png", "NO IMAGE YET.png", "No Photo Available.svg", "No Screenshot.svg", "No-image-available.jpg", "Null.png", "PictureNeeded.gif", "Place holder.jpg", "Unbenannt.JPG", "UploadACopyrightFreeImage.svg", "UploadAnImage.gif", "UploadAnImage.svg", "UploadAnImageShort.svg", "CarersLogo.gif", "Diagram Needed.svg", "No male portrait.svg", "NoDVDcover copy.png", "Placeholder barnstar ribbon.png", "Project Trains no image.png", "Image-request.png", } function i.IsPlaceholder(image) -- change underscores to spaces image = mw.ustring.gsub(image, "_", " "); assert(image ~= nil, 'mw.ustring.gsub(image, "_", " ") must not return nil') -- if image starts with [[ then remove that and anything after | if mw.ustring.sub(image,1,2) == "[[" then image = mw.ustring.sub(image,3); image = mw.ustring.gsub(image, "([^|]*)|.*", "%1"); assert(image ~= nil, 'mw.ustring.gsub(image, "([^|]*)|.*", "%1") must not return nil') end -- Trim spaces image = mw.ustring.gsub(image, '^[ ]*(.-)[ ]*$', '%1'); assert(image ~= nil, "mw.ustring.gsub(image, '^[ ]*(.-)[ ]*$', '%1') must not return nil") -- remove prefix if exists local allNames = mw.site.namespaces[6].aliases allNames[#allNames + 1] = mw.site.namespaces[6].name allNames[#allNames + 1] = mw.site.namespaces[6].canonicalName for i, name in ipairs(allNames) do if mw.ustring.lower(mw.ustring.sub(image, 1, mw.ustring.len(name) + 1)) == mw.ustring.lower(name .. ":") then image = mw.ustring.sub(image, mw.ustring.len(name) + 2); break end end -- Trim spaces image = mw.ustring.gsub(image, '^[ ]*(.-)[ ]*$', '%1'); -- capitalise first letter image = mw.ustring.upper(mw.ustring.sub(image,1,1)) .. mw.ustring.sub(image,2); for i,j in pairs(placeholder_image) do if image == j then return true end end return false end function i.InfoboxImage(frame) local image = frame.args["image"]; if image == "" or image == nil then return ""; end if image == "&nbsp;" then return image; end if frame.args["suppressplaceholder"] ~= "no" then if i.IsPlaceholder(image) == true then return ""; end end if mw.ustring.lower(mw.ustring.sub(image,1,5)) == "http:" then return ""; end if mw.ustring.lower(mw.ustring.sub(image,1,6)) == "[http:" then return ""; end if mw.ustring.lower(mw.ustring.sub(image,1,7)) == "[[http:" then return ""; end if mw.ustring.lower(mw.ustring.sub(image,1,6)) == "https:" then return ""; end if mw.ustring.lower(mw.ustring.sub(image,1,7)) == "[https:" then return ""; end if mw.ustring.lower(mw.ustring.sub(image,1,8)) == "[[https:" then return ""; end if mw.ustring.sub(image,1,2) == "[[" then -- search for thumbnail images and add to tracking cat if found if mw.title.getCurrentTitle().namespace == 0 and (mw.ustring.find(image, "|%s*thumb%s*[|%]]") or mw.ustring.find(image, "|%s*thumbnail%s*[|%]]")) then return image .. "[[Category:Infobox内でサムネイル画像を使用しているページ]]"; else return image; end elseif mw.ustring.sub(image,1,2) == "{{" and mw.ustring.sub(image,1,3) ~= "{{{" then return image; elseif mw.ustring.sub(image,1,1) == "<" then return image; elseif mw.ustring.sub(image,1,5) == mw.ustring.char(127).."UNIQ" then -- Found strip marker at begining, so pass don't process at all return image; elseif mw.ustring.sub(image,4,9) == "`UNIQ-" then -- Found strip marker at begining, so pass don't process at all return image; else local result = ""; local page = frame.args["page"]; local size = frame.args["size"]; local maxsize = frame.args["maxsize"]; local sizedefault = frame.args["sizedefault"]; local alt = frame.args["alt"]; local link = frame.args["link"]; local title = frame.args["title"]; local border = frame.args["border"]; local upright = frame.args["upright"] or ""; local thumbtime = frame.args["thumbtime"] or ""; local center= frame.args["center"]; -- remove prefix if exists local allNames = mw.site.namespaces[6].aliases allNames[#allNames + 1] = mw.site.namespaces[6].name allNames[#allNames + 1] = mw.site.namespaces[6].canonicalName for i, name in ipairs(allNames) do if mw.ustring.lower(mw.ustring.sub(image, 1, mw.ustring.len(name) + 1)) == mw.ustring.lower(name .. ":") then image = mw.ustring.sub(image, mw.ustring.len(name) + 2); break end end if maxsize ~= "" and maxsize ~= nil then -- if no sizedefault then set to maxsize if sizedefault == "" or sizedefault == nil then sizedefault = maxsize end -- check to see if size bigger than maxsize if size ~= "" and size ~= nil then local sizenumber = tonumber(mw.ustring.match(size,"%d*")) or 0; local maxsizenumber = tonumber(mw.ustring.match(maxsize,"%d*")) or 0; if sizenumber>maxsizenumber and maxsizenumber>0 then size = maxsize; end end end -- add px to size if just a number if (tonumber(size) or 0) > 0 then size = size .. "px"; end result = "[[File:" .. image; if page ~= "" and page ~= nil then result = result .. "|page=" .. page; end if size ~= "" and size ~= nil then result = result .. "|" .. size; elseif sizedefault ~= "" and sizedefault ~= nil then result = result .. "|" .. sizedefault; else result = result .. "|frameless"; end if center == "yes" then result = result .. "|center" end if alt ~= "" and alt ~= nil then result = result .. "|alt=" .. alt; end if link ~= "" and link ~= nil then result = result .. "|link=" .. link; end if border == "yes" then result = result .. "|border"; end if upright == "yes" then result = result .. "|upright"; elseif upright ~= "" then result = result .. "|upright=" .. upright; end if thumbtime ~= "" then result = result .. "|thumbtime=" .. thumbtime; end if title ~= "" and title ~= nil then result = result .. "|" .. title; elseif alt ~= "" and alt ~= nil then result = result .. "|" .. alt; end result = result .. "]]"; return result; end end return i; 911bef64bf4e15e1a4bba43a593741e72f7762bc モジュール:Message box 828 38 80 79 2019-06-23T17:10:35Z Ochaochaocha3 1 1版 をインポートしました Scribunto text/plain -- This is a meta-module for producing message box templates, including -- {{mbox}}, {{ambox}}, {{imbox}}, {{tmbox}}, {{ombox}}, {{cmbox}} and {{fmbox}}. -- Load necessary modules. require('Module:No globals') local getArgs local categoryHandler = require('Module:Category handler')._main local yesno = require('Module:Yesno') -- Get a language object for formatDate and ucfirst. local lang = mw.language.getContentLanguage() -------------------------------------------------------------------------------- -- Helper functions -------------------------------------------------------------------------------- local function getTitleObject(...) -- Get the title object, passing the function through pcall -- in case we are over the expensive function count limit. local success, title = pcall(mw.title.new, ...) if success then return title end end local function union(t1, t2) -- Returns the union of two arrays. local vals = {} for i, v in ipairs(t1) do vals[v] = true end for i, v in ipairs(t2) do vals[v] = true end local ret = {} for k in pairs(vals) do table.insert(ret, k) end table.sort(ret) return ret end local function getArgNums(args, prefix) local nums = {} for k, v in pairs(args) do local num = mw.ustring.match(tostring(k), '^' .. prefix .. '([1-9]%d*)$') if num then table.insert(nums, tonumber(num)) end end table.sort(nums) return nums end -------------------------------------------------------------------------------- -- Box class definition -------------------------------------------------------------------------------- local MessageBox = {} MessageBox.__index = MessageBox function MessageBox.new(boxType, args, cfg) args = args or {} local obj = {} -- Set the title object and the namespace. obj.title = getTitleObject(args.page) or mw.title.getCurrentTitle() -- Set the config for our box type. obj.cfg = cfg[boxType] if not obj.cfg then local ns = obj.title.namespace -- boxType is "mbox" or invalid input if ns == 0 then obj.cfg = cfg.ambox -- main namespace elseif ns == 6 then obj.cfg = cfg.imbox -- file namespace elseif ns == 14 then obj.cfg = cfg.cmbox -- category namespace else local nsTable = mw.site.namespaces[ns] if nsTable and nsTable.isTalk then obj.cfg = cfg.tmbox -- any talk namespace else obj.cfg = cfg.ombox -- other namespaces or invalid input end end end -- Set the arguments, and remove all blank arguments except for the ones -- listed in cfg.allowBlankParams. do local newArgs = {} for k, v in pairs(args) do if v ~= '' then newArgs[k] = v end end for i, param in ipairs(obj.cfg.allowBlankParams or {}) do newArgs[param] = args[param] end obj.args = newArgs end -- Define internal data structure. obj.categories = {} obj.classes = {} return setmetatable(obj, MessageBox) end function MessageBox:addCat(ns, cat, sort) if not cat then return nil end if sort then cat = string.format('[[Category:%s|%s]]', cat, sort) else cat = string.format('[[Category:%s]]', cat) end self.categories[ns] = self.categories[ns] or {} table.insert(self.categories[ns], cat) end function MessageBox:addClass(class) if not class then return nil end table.insert(self.classes, class) end function MessageBox:setParameters() local args = self.args local cfg = self.cfg -- Get type data. self.type = args.type local typeData = cfg.types[self.type] self.invalidTypeError = cfg.showInvalidTypeError and self.type and not typeData typeData = typeData or cfg.types[cfg.default] self.typeClass = typeData.class self.typeImage = typeData.image -- Find if the box has been wrongly substituted. self.isSubstituted = cfg.substCheck and args.subst == 'SUBST' -- Find whether we are using a small message box. self.isSmall = cfg.allowSmall and ( cfg.smallParam and args.small == cfg.smallParam or not cfg.smallParam and yesno(args.small) ) -- Add attributes, classes and styles. self.id = args.id self:addClass( cfg.usePlainlinksParam and yesno(args.plainlinks or true) and 'plainlinks' ) for _, class in ipairs(cfg.classes or {}) do self:addClass(class) end if self.isSmall then self:addClass(cfg.smallClass or 'mbox-small') end self:addClass(self.typeClass) self:addClass(args.class) self.style = args.style self.attrs = args.attrs -- Set text style. self.textstyle = args.textstyle -- Find if we are on the template page or not. This functionality is only -- used if useCollapsibleTextFields is set, or if both cfg.templateCategory -- and cfg.templateCategoryRequireName are set. self.useCollapsibleTextFields = cfg.useCollapsibleTextFields if self.useCollapsibleTextFields or cfg.templateCategory and cfg.templateCategoryRequireName then self.name = args.name if self.name then local templateName = mw.ustring.match( self.name, '^[tT][eE][mM][pP][lL][aA][tT][eE][%s_]*:[%s_]*(.*)$' ) or self.name templateName = 'Template:' .. templateName self.templateTitle = getTitleObject(templateName) end self.isTemplatePage = self.templateTitle and mw.title.equals(self.title, self.templateTitle) end -- Process data for collapsible text fields. At the moment these are only -- used in {{ambox}}. if self.useCollapsibleTextFields then -- Get the self.issue value. if self.isSmall and args.smalltext then self.issue = args.smalltext else local sect if args.sect == '' then sect = 'This ' .. (cfg.sectionDefault or 'page') elseif type(args.sect) == 'string' then sect = 'This ' .. args.sect end local issue = args.issue issue = type(issue) == 'string' and issue ~= '' and issue or nil local text = args.text text = type(text) == 'string' and text or nil local issues = {} table.insert(issues, sect) table.insert(issues, issue) table.insert(issues, text) self.issue = table.concat(issues, ' ') end -- Get the self.talk value. local talk = args.talk -- Show talk links on the template page or template subpages if the talk -- parameter is blank. if talk == '' and self.templateTitle and ( mw.title.equals(self.templateTitle, self.title) or self.title:isSubpageOf(self.templateTitle) ) then talk = '#' elseif talk == '' then talk = nil end if talk then -- If the talk value is a talk page, make a link to that page. Else -- assume that it's a section heading, and make a link to the talk -- page of the current page with that section heading. local talkTitle = getTitleObject(talk) local talkArgIsTalkPage = true if not talkTitle or not talkTitle.isTalkPage then talkArgIsTalkPage = false talkTitle = getTitleObject( self.title.text, mw.site.namespaces[self.title.namespace].talk.id ) end if talkTitle and talkTitle.exists then local talkText = '関連議論は' if talkArgIsTalkPage then talkText = string.format( '%s[[%s|%s]]に存在するかもしれません。', talkText, talk, talkTitle.prefixedText ) else talkText = string.format( '%s[[%s#%s|ノートページ]]に存在するかもしれません。', talkText, talkTitle.prefixedText, talk ) end self.talk = talkText end end -- Get other values. self.fix = args.fix ~= '' and args.fix or nil local date if args.date and args.date ~= '' then date = args.date elseif args.date == '' and self.isTemplatePage then date = lang:formatDate('Y年F') end if date then self.date = string.format(" <small>(%s)</small>", date) end self.info = args.info end -- Set the non-collapsible text field. At the moment this is used by all box -- types other than ambox, and also by ambox when small=yes. if self.isSmall then self.text = args.smalltext or args.text else self.text = args.text end -- Set the below row. self.below = cfg.below and args.below -- General image settings. self.imageCellDiv = not self.isSmall and cfg.imageCellDiv self.imageEmptyCell = cfg.imageEmptyCell if cfg.imageEmptyCellStyle then self.imageEmptyCellStyle = 'border:none;padding:0px;width:1px' end -- Left image settings. local imageLeft = self.isSmall and args.smallimage or args.image if cfg.imageCheckBlank and imageLeft ~= 'blank' and imageLeft ~= 'none' or not cfg.imageCheckBlank and imageLeft ~= 'none' then self.imageLeft = imageLeft if not imageLeft then local imageSize = self.isSmall and (cfg.imageSmallSize or '30x30px') or '40x40px' self.imageLeft = string.format('[[File:%s|%s|link=|alt=]]', self.typeImage or 'Imbox notice.png', imageSize) end end -- Right image settings. local imageRight = self.isSmall and args.smallimageright or args.imageright if not (cfg.imageRightNone and imageRight == 'none') then self.imageRight = imageRight end end function MessageBox:setMainspaceCategories() local args = self.args local cfg = self.cfg if not cfg.allowMainspaceCategories then return nil end local nums = {} for _, prefix in ipairs{'cat', 'category', 'all'} do args[prefix .. '1'] = args[prefix] nums = union(nums, getArgNums(args, prefix)) end -- The following is roughly equivalent to the old {{Ambox/category}}. local date = args.date date = type(date) == 'string' and date local preposition = '/' for _, num in ipairs(nums) do local mainCat = args['cat' .. tostring(num)] or args['category' .. tostring(num)] local allCat = args['all' .. tostring(num)] mainCat = type(mainCat) == 'string' and mainCat allCat = type(allCat) == 'string' and allCat if mainCat and date and date ~= '' then local catTitle = string.format('%s%s%s', mainCat, preposition, date) self:addCat(0, catTitle) catTitle = getTitleObject('Category:' .. catTitle) if not catTitle or not catTitle.exists then self:addCat(0, '貼り付け日が正しくないテンプレートのある記事') end elseif mainCat and (not date or date == '') then self:addCat(0, mainCat) end if allCat then self:addCat(0, allCat) end end end function MessageBox:setTemplateCategories() local args = self.args local cfg = self.cfg -- Add template categories. if cfg.templateCategory then if cfg.templateCategoryRequireName then if self.isTemplatePage then self:addCat(10, cfg.templateCategory) end elseif not self.title.isSubpage then self:addCat(10, cfg.templateCategory) end end -- Add template error categories. if cfg.templateErrorCategory then local templateErrorCategory = cfg.templateErrorCategory local templateCat, templateSort if not self.name and not self.title.isSubpage then templateCat = templateErrorCategory elseif self.isTemplatePage then local paramsToCheck = cfg.templateErrorParamsToCheck or {} local count = 0 for i, param in ipairs(paramsToCheck) do if not args[param] then count = count + 1 end end if count > 0 then templateCat = templateErrorCategory templateSort = tostring(count) end if self.categoryNums and #self.categoryNums > 0 then templateCat = templateErrorCategory templateSort = 'C' end end self:addCat(10, templateCat, templateSort) end end function MessageBox:setAllNamespaceCategories() -- Set categories for all namespaces. if self.invalidTypeError then local allSort = (self.title.namespace == 0 and 'Main:' or '') .. self.title.prefixedText self:addCat('all', 'パラメータの修正が必要なメッセージボックス', allSort) end if self.isSubstituted then self:addCat('all', '正しく置き換えられていないテンプレートがあるページ') end end function MessageBox:setCategories() if self.title.namespace == 0 then self:setMainspaceCategories() elseif self.title.namespace == 10 then self:setTemplateCategories() end self:setAllNamespaceCategories() end function MessageBox:renderCategories() -- Convert category tables to strings and pass them through -- [[Module:Category handler]]. return categoryHandler{ main = table.concat(self.categories[0] or {}), template = table.concat(self.categories[10] or {}), all = table.concat(self.categories.all or {}), nocat = self.args.nocat, page = self.args.page } end function MessageBox:export() local root = mw.html.create() -- Add the subst check error. if self.isSubstituted and self.name then root:tag('b') :addClass('error') :wikitext(string.format( 'テンプレート<code>%s[[Template:%s|%s]]%s</code>が正しく置き換えられませんでした。', mw.text.nowiki('{{'), self.name, self.name, mw.text.nowiki('}}') )) end -- Create the box table. local boxTable = root:tag('table') boxTable:attr('id', self.id or nil) for i, class in ipairs(self.classes or {}) do boxTable:addClass(class or nil) end boxTable :cssText(self.style or nil) :attr('role', 'presentation') if self.attrs then boxTable:attr(self.attrs) end -- Add the left-hand image. local row = boxTable:tag('tr') if self.imageLeft then local imageLeftCell = row:tag('td'):addClass('mbox-image') if self.imageCellDiv then -- If we are using a div, redefine imageLeftCell so that the image -- is inside it. Divs use style="width: 52px;", which limits the -- image width to 52px. If any images in a div are wider than that, -- they may overlap with the text or cause other display problems. imageLeftCell = imageLeftCell:tag('div'):css('width', '52px') end imageLeftCell:wikitext(self.imageLeft or nil) elseif self.imageEmptyCell then -- Some message boxes define an empty cell if no image is specified, and -- some don't. The old template code in templates where empty cells are -- specified gives the following hint: "No image. Cell with some width -- or padding necessary for text cell to have 100% width." row:tag('td') :addClass('mbox-empty-cell') :cssText(self.imageEmptyCellStyle or nil) end -- Add the text. local textCell = row:tag('td'):addClass('mbox-text') if self.useCollapsibleTextFields then -- The message box uses advanced text parameters that allow things to be -- collapsible. At the moment, only ambox uses this. textCell:cssText(self.textstyle or nil) local textCellSpan = textCell:tag('span') textCellSpan :addClass('mbox-text-span') :wikitext(self.issue or nil) if not self.isSmall then textCellSpan:tag('span') :addClass('hide-when-compact') :wikitext(self.talk and (' ' .. self.talk) or nil) :wikitext(self.fix and (' ' .. self.fix) or nil) end textCellSpan:wikitext(self.date and (' ' .. self.date) or nil) if not self.isSmall then textCellSpan :tag('span') :addClass('hide-when-compact') :wikitext(self.info and (' ' .. self.info) or nil) end else -- Default text formatting - anything goes. textCell :cssText(self.textstyle or nil) :wikitext(self.text or nil) end -- Add the right-hand image. if self.imageRight then local imageRightCell = row:tag('td'):addClass('mbox-imageright') if self.imageCellDiv then -- If we are using a div, redefine imageRightCell so that the image -- is inside it. imageRightCell = imageRightCell:tag('div'):css('width', '52px') end imageRightCell :wikitext(self.imageRight or nil) end -- Add the below row. if self.below then boxTable:tag('tr') :tag('td') :attr('colspan', self.imageRight and '3' or '2') :addClass('mbox-text') :cssText(self.textstyle or nil) :wikitext(self.below or nil) end -- Add error message for invalid type parameters. if self.invalidTypeError then root:tag('div') :css('text-align', 'center') :wikitext(string.format( 'このメッセージボックスには無効な"type=%s"というパラメータが指定されているため修正が必要です。', self.type or '' )) end -- Add categories. root:wikitext(self:renderCategories() or nil) return tostring(root) end -------------------------------------------------------------------------------- -- Exports -------------------------------------------------------------------------------- local p, mt = {}, {} function p._exportClasses() -- For testing. return { MessageBox = MessageBox } end function p.main(boxType, args, cfgTables) local box = MessageBox.new(boxType, args, cfgTables or mw.loadData('Module:Message box/configuration')) box:setParameters() box:setCategories() return box:export() end function mt.__index(t, k) return function (frame) if not getArgs then getArgs = require('Module:Arguments').getArgs end return t.main(k, getArgs(frame, {trim = false, removeBlanks = false})) end end return setmetatable(p, mt) 3dd60a769a5d1315faa4661358115f17ffa99687 モジュール:Message box/configuration 828 39 82 81 2019-06-23T17:10:35Z Ochaochaocha3 1 1版 をインポートしました Scribunto text/plain -------------------------------------------------------------------------------- -- Message box configuration -- -- -- -- This module contains configuration data for [[Module:Message box]]. -- -------------------------------------------------------------------------------- return { ambox = { types = { speedy = { class = 'ambox-speedy', image = 'Ambox warning pn.svg' }, delete = { class = 'ambox-delete', image = 'Ambox warning pn.svg' }, content = { class = 'ambox-content', image = 'Ambox important.svg' }, style = { class = 'ambox-style', image = 'Edit-clear.svg' }, move = { class = 'ambox-move', image = 'Merge-split-transwiki default.svg' }, protection = { class = 'ambox-protection', image = 'Padlock-silver-medium.svg' }, notice = { class = 'ambox-notice', image = 'Information icon4.svg' } }, default = 'notice', allowBlankParams = {'talk', 'sect', 'date', 'issue', 'fix', 'subst', 'hidden'}, allowSmall = true, smallParam = 'left', smallClass = 'mbox-small-left', substCheck = true, classes = {--[['metadata',]] 'plainlinks', 'ambox'}, imageEmptyCell = true, imageCheckBlank = true, imageSmallSize = '20x20px', imageCellDiv = true, useCollapsibleTextFields = true, imageRightNone = true, sectionDefault = '記事', allowMainspaceCategories = true, templateCategory = '記事メッセージボックス', templateCategoryRequireName = true, templateErrorCategory = 'パラメータ指定の無い記事メッセージボックス', templateErrorParamsToCheck = {'issue', 'fix', 'subst'} }, cmbox = { types = { speedy = { class = 'cmbox-speedy', image = 'Ambox warning pn.svg' }, delete = { class = 'cmbox-delete', image = 'Ambox warning pn.svg' }, content = { class = 'cmbox-content', image = 'Ambox important.svg' }, style = { class = 'cmbox-style', image = 'Edit-clear.svg' }, move = { class = 'cmbox-move', image = 'Merge-split-transwiki default.svg' }, protection = { class = 'cmbox-protection', image = 'Padlock-silver-medium.svg' }, notice = { class = 'cmbox-notice', image = 'Information icon4.svg' } }, default = 'notice', showInvalidTypeError = true, classes = {'plainlinks', 'cmbox'}, imageEmptyCell = true }, fmbox = { types = { warning = { class = 'fmbox-warning', image = 'Ambox warning pn.svg' }, editnotice = { class = 'fmbox-editnotice', image = 'Information icon4.svg' }, system = { class = 'fmbox-system', image = 'Information icon4.svg' } }, default = 'system', showInvalidTypeError = true, classes = {'plainlinks', 'fmbox'}, imageEmptyCell = false, imageRightNone = false }, imbox = { types = { speedy = { class = 'imbox-speedy', image = 'Ambox warning pn.svg' }, delete = { class = 'imbox-delete', image = 'Ambox warning pn.svg' }, content = { class = 'imbox-content', image = 'Ambox important.svg' }, style = { class = 'imbox-style', image = 'Edit-clear.svg' }, move = { class = 'imbox-move', image = 'Merge-split-transwiki default.svg' }, protection = { class = 'imbox-protection', image = 'Padlock-silver-medium.svg' }, license = { class = 'imbox-license licensetpl', image = 'Imbox license.png' -- @todo We need an SVG version of this }, featured = { class = 'imbox-featured', image = 'Cscr-featured.svg' }, notice = { class = 'imbox-notice', image = 'Information icon4.svg' } }, default = 'notice', showInvalidTypeError = true, classes = {'imbox'}, usePlainlinksParam = true, imageEmptyCell = true, below = true, templateCategory = 'ファイルメッセージボックス' }, ombox = { types = { speedy = { class = 'ombox-speedy', image = 'Ambox warning pn.svg' }, delete = { class = 'ombox-delete', image = 'Ambox warning pn.svg' }, content = { class = 'ombox-content', image = 'Ambox important.svg' }, style = { class = 'ombox-style', image = 'Edit-clear.svg' }, move = { class = 'ombox-move', image = 'Merge-split-transwiki default.svg' }, protection = { class = 'ombox-protection', image = 'Padlock-silver-medium.svg' }, notice = { class = 'ombox-notice', image = 'Information icon4.svg' } }, default = 'notice', showInvalidTypeError = true, classes = {'plainlinks', 'ombox'}, allowSmall = true, imageEmptyCell = true, imageRightNone = true }, tmbox = { types = { speedy = { class = 'tmbox-speedy', image = 'Ambox warning pn.svg' }, delete = { class = 'tmbox-delete', image = 'Ambox warning pn.svg' }, content = { class = 'tmbox-content', image = 'Ambox important.svg' }, style = { class = 'tmbox-style', image = 'Edit-clear.svg' }, move = { class = 'tmbox-move', image = 'Merge-split-transwiki default.svg' }, protection = { class = 'tmbox-protection', image = 'Padlock-silver-medium.svg' }, notice = { class = 'tmbox-notice', image = 'Information icon4.svg' } }, default = 'notice', showInvalidTypeError = true, classes = {'plainlinks', 'tmbox'}, allowSmall = true, imageRightNone = true, imageEmptyCell = true, imageEmptyCellStyle = true, templateCategory = 'ノートページメッセージボックス' } } b6b39dad7bd221ad9a2122ccd6ba7f188ccf3bd4 モジュール:Namespace detect/config 828 40 84 83 2019-06-23T17:10:35Z Ochaochaocha3 1 1版 をインポートしました Scribunto text/plain -------------------------------------------------------------------------------- -- Namespace detect configuration data -- -- -- -- This module stores configuration data for Module:Namespace detect. Here -- -- you can localise the module to your wiki's language. -- -- -- -- To activate a configuration item, you need to uncomment it. This means -- -- that you need to remove the text "-- " at the start of the line. -- -------------------------------------------------------------------------------- local cfg = {} -- Don't edit this line. -------------------------------------------------------------------------------- -- Parameter names -- -- These configuration items specify custom parameter names. Values added -- -- here will work in addition to the default English parameter names. -- -- To add one extra name, you can use this format: -- -- -- -- cfg.foo = 'parameter name' -- -- -- -- To add multiple names, you can use this format: -- -- -- -- cfg.foo = {'parameter name 1', 'parameter name 2', 'parameter name 3'} -- -------------------------------------------------------------------------------- ---- This parameter displays content for the main namespace: -- cfg.main = 'main' ---- This parameter displays in talk namespaces: -- cfg.talk = 'talk' ---- This parameter displays content for "other" namespaces (namespaces for which ---- parameters have not been specified): -- cfg.other = 'other' ---- This parameter makes talk pages behave as though they are the corresponding ---- subject namespace. Note that this parameter is used with [[Module:Yesno]]. ---- Edit that module to change the default values of "yes", "no", etc. -- cfg.subjectns = 'subjectns' ---- This parameter sets a demonstration namespace: -- cfg.demospace = 'demospace' ---- This parameter sets a specific page to compare: cfg.demopage = 'page' -------------------------------------------------------------------------------- -- Table configuration -- -- These configuration items allow customisation of the "table" function, -- -- used to generate a table of possible parameters in the module -- -- documentation. -- -------------------------------------------------------------------------------- ---- The header for the namespace column in the wikitable containing the list of ---- possible subject-space parameters. -- cfg.wikitableNamespaceHeader = 'Namespace' ---- The header for the wikitable containing the list of possible subject-space ---- parameters. -- cfg.wikitableAliasesHeader = 'Aliases' -------------------------------------------------------------------------------- -- End of configuration data -- -------------------------------------------------------------------------------- return cfg -- Don't edit this line. 0e4ff08d13c4b664d66b32c232deb129b77c1a56 モジュール:Namespace detect/data 828 41 86 85 2019-06-23T17:10:35Z Ochaochaocha3 1 1版 をインポートしました Scribunto text/plain -------------------------------------------------------------------------------- -- Namespace detect data -- -- This module holds data for [[Module:Namespace detect]] to be loaded per -- -- page, rather than per #invoke, for performance reasons. -- -------------------------------------------------------------------------------- local cfg = require('Module:Namespace detect/config') local function addKey(t, key, defaultKey) if key ~= defaultKey then t[#t + 1] = key end end -- Get a table of parameters to query for each default parameter name. -- This allows wikis to customise parameter names in the cfg table while -- ensuring that default parameter names will always work. The cfg table -- values can be added as a string, or as an array of strings. local defaultKeys = { 'main', 'talk', 'other', 'subjectns', 'demospace', 'demopage' } local argKeys = {} for i, defaultKey in ipairs(defaultKeys) do argKeys[defaultKey] = {defaultKey} end for defaultKey, t in pairs(argKeys) do local cfgValue = cfg[defaultKey] local cfgValueType = type(cfgValue) if cfgValueType == 'string' then addKey(t, cfgValue, defaultKey) elseif cfgValueType == 'table' then for i, key in ipairs(cfgValue) do addKey(t, key, defaultKey) end end cfg[defaultKey] = nil -- Free the cfg value as we don't need it any more. end local function getParamMappings() --[[ -- Returns a table of how parameter names map to namespace names. The keys -- are the actual namespace names, in lower case, and the values are the -- possible parameter names for that namespace, also in lower case. The -- table entries are structured like this: -- { -- [''] = {'main'}, -- ['wikipedia'] = {'wikipedia', 'project', 'wp'}, -- ... -- } --]] local mappings = {} local mainNsName = mw.site.subjectNamespaces[0].name mainNsName = mw.ustring.lower(mainNsName) mappings[mainNsName] = mw.clone(argKeys.main) mappings['talk'] = mw.clone(argKeys.talk) for nsid, ns in pairs(mw.site.subjectNamespaces) do if nsid ~= 0 then -- Exclude main namespace. local nsname = mw.ustring.lower(ns.name) local canonicalName = mw.ustring.lower(ns.canonicalName) mappings[nsname] = {nsname} if canonicalName ~= nsname then table.insert(mappings[nsname], canonicalName) end for _, alias in ipairs(ns.aliases) do table.insert(mappings[nsname], mw.ustring.lower(alias)) end end end return mappings end return { argKeys = argKeys, cfg = cfg, mappings = getParamMappings() } d224f42a258bc308ef3ad8cc8686cd7a4f47d005 モジュール:No globals 828 42 88 87 2019-06-23T17:10:36Z Ochaochaocha3 1 1版 をインポートしました Scribunto text/plain local mt = getmetatable(_G) or {} function mt.__index (t, k) if k ~= 'arg' then error('Tried to read nil global ' .. tostring(k), 2) end return nil end function mt.__newindex(t, k, v) if k ~= 'arg' then error('Tried to write global ' .. tostring(k), 2) end rawset(t, k, v) end setmetatable(_G, mt) 8ce3969f7d53b08bd00dabe4cc9780bc6afd412a モジュール:Yesno 828 43 90 89 2019-06-23T17:10:36Z Ochaochaocha3 1 1版 をインポートしました Scribunto text/plain -- Function allowing for consistent treatment of boolean-like wikitext input. -- It works similarly to the template {{yesno}}. return function (val, default) -- If your wiki uses non-ascii characters for any of "yes", "no", etc., you -- should replace "val:lower()" with "mw.ustring.lower(val)" in the -- following line. val = type(val) == 'string' and val:lower() or val if val == nil then return nil elseif val == true or val == 'yes' or val == 'y' or val == 'true' or val == 't' or tonumber(val) == 1 then return true elseif val == false or val == 'no' or val == 'n' or val == 'false' or val == 'f' or tonumber(val) == 0 then return false else return default end end 12981c9a31eb2b0af1be4f16fc0642e180eac8c2 テンプレート:TRPGツール概要 10 44 91 2019-06-23T17:14:05Z Ochaochaocha3 1 ページの作成:「<includeonly>{{Infobox | name = TRPGツール概要 | aboveclass = infobox-above | above = {{{タイトル|{{PAGENAME}}}}} | image = {{#invoke:InfoboxImage|InfoboxImage|i…」 wikitext text/x-wiki <includeonly>{{Infobox | name = TRPGツール概要 | aboveclass = infobox-above | above = {{{タイトル|{{PAGENAME}}}}} | image = {{#invoke:InfoboxImage|InfoboxImage|image={{{image|}}}|size={{{image_size|}}}|sizedefault=frameless|upright=1.15|alt={{{alt|}}}}} | caption = {{{キャプション|}}} | rowclass = infobox-row | label0 = 開発者 | data0 = {{{開発者|}}} | label10 = 公式サイト | data10 = {{{公式サイト|}}} | label11 = 公式マニュアル | data11 = {{{公式マニュアル|}}} | label12 = GitHubリポジトリ | data12 = {{{GitHubリポジトリ|}}} | label20 = 使用技術 | data20 = {{{使用技術|}}} }}</includeonly><noinclude> {{Documentation}}</noinclude> 1589b660a7cc7bee8577fe11b3bd3ac1533d69e9 テンプレート:Documentation subpage 10 45 92 2019-06-23T17:19:21Z Ochaochaocha3 1 ページの作成:「<onlyinclude><includeonly>{{ #ifeq: {{lc:{{SUBPAGENAME}}}} | {{{override|doc}}} | <!-- doc page --> </includeonly>{{ #ifeq: {{{doc-notice|show}}} | show | <!-…」 wikitext text/x-wiki <onlyinclude><includeonly>{{ #ifeq: {{lc:{{SUBPAGENAME}}}} | {{{override|doc}}} | <!-- doc page --> </includeonly>{{ #ifeq: {{{doc-notice|show}}} | show | <!-- doc-notice show -->{{Ombox | type = notice | image = [[File:Edit-copy green.svg|40px]] | text = '''これは{{{1|[[{{SUBJECTSPACE}}:{{BASEPAGENAME}}]]}}}の[[Help:テンプレートの説明文|解説]][[Help:サブページ|サブページ]]です。'''<br />使用方法、[[Help:カテゴリ|カテゴリ]]、およびその他{{{種類|{{ #if: {{SUBJECTSPACE}} |{{SUBJECTSPACE}}ページ|記事}}}}}自体に含まれない情報を収容しています。 }} | <!-- doc-notice hide --> }}<includeonly> |<!-- not doc --> }}</includeonly><includeonly>{{ #ifeq: {{SUBPAGENAME}} | doc | {{ #ifeq: {{NAMESPACE}} | {{ns:10}} | [[Category:テンプレート文書|{{PAGENAME}}]] }} }}</includeonly></onlyinclude> {{Documentation}} 9121f78d57f3fd8fd374022d256a177a4fbc4dfd テンプレート:Documentation subpage/doc 10 46 94 93 2019-06-23T17:20:21Z Ochaochaocha3 1 1版 をインポートしました wikitext text/x-wiki <noinclude>{{Documentation subpage}}</noinclude> このテンプレートは、(主にテンプレートの)[[Help:テンプレートの説明文|解説]][[Help:サブページ|サブページ]]であることを告知するために使います。 __TOC__ == 使い方 == === 基本 === 次のコードをページの冒頭に張るだけです: &lt;noinclude&gt;<nowiki>{{Documentation subpage}}</nowiki>&lt;/noinclude&gt; === 解説の対象を指定する === 次のように解説の対象を指定することもできます: &lt;noinclude&gt;<nowiki>{{Documentation subpage|[[Template:X]]}}</nowiki>&lt;/noinclude&gt; === 種類を指定する === 次のように解説の対象の種類を指定することもできます: &lt;noinclude&gt;<nowiki>{{Documentation subpage|種類=[[Help:テンプレート|テンプレート]]}}</nowiki>&lt;/noinclude&gt; == 引数 == {| class="wikitable" border="1" |+ 引数の一覧 ! 引数 !! 指定内容 !! 既定値 !! 説明 |- ! style="text-align:left;" | 1 | ページ名 || <nowiki>[[{{SUBJECTSPACE}}:{{BASEPAGENAME}}]]</nowiki> || 解説の対象を指定。 |- ! style="text-align:left;" | override | サブページ名 || doc || そのテンプレートは、この引数で指定されたサブページ名を持つページでだけ機能します。 |- ! style="text-align:left;" | doc-notice | 任意の文字列 || show || 「show」以外を指定すると、このテンプレートは告知を出力しません。 |- ! style="text-align:left;" | 種類 | 任意の文字列 || {{Tl|SUBJECTSPACE}}ページ<small>(標準名前空間以外のとき)</small><br />記事<small>(標準名前空間のとき)</small>|| 解説の対象の種類を指定。 |} == カテゴリ == このテンプレートは、貼り付けられたページに次のカテゴリを適用します: {| class="wikitable" border="1" |+ 適用するカテゴリの一覧 ! カテゴリ !! ソートキー !! 解説 |- ! style="text-align:left;" | [[:Category:テンプレート文書]] | <nowiki>{{PAGENAME}}</nowiki> | {{ns:10}} 名前空間にあるページのみをカテゴライズします。 |} == 関連項目 == * [[Help:テンプレートの説明文]] * {{Tl|Documentation}} * {{Tl|Template sandbox notice}} * {{Tl|Template test cases notice}} <includeonly> {{デフォルトソート:{{PAGENAME}}}} [[Category:テンプレート文書| ]] [[Category:テンプレート用テンプレート]] </includeonly> b604d646d8fc7c57468109d0fc6b4ba923a451b1 テンプレート:Tl 10 47 96 95 2019-06-23T17:20:22Z Ochaochaocha3 1 1版 をインポートしました wikitext text/x-wiki <onlyinclude>{{[[Template:{{{1}}}|{{{1}}}]]}}</onlyinclude>{{Documentation}} <!-- カテゴリと言語間リンクはここではなく、/doc サブページに追加してください --> <!-- Add cats and interwikis to the /doc subpage, not here! --> 9c7ac163470965eadcc21e01017e661bc5f001f9 テンプレート:TRPGツール概要/doc 10 48 97 2019-06-23T17:21:07Z Ochaochaocha3 1 ページの作成:「<noinclude><!-- カテゴリと言語間リンクはこのページの下に加えてください。 --> {{Documentation subpage}}</noinclude> {{概要テンプレート…」 wikitext text/x-wiki <noinclude><!-- カテゴリと言語間リンクはこのページの下に加えてください。 --> {{Documentation subpage}}</noinclude> {{概要テンプレート・編集|テンプレート:TRPGツール概要}} TRPGツールのページの上部に書く概要部分を、「[[テンプレート:Infobox]]」を用いて表示します。 == 使い方 == {{TRPGツール概要 | 開発者 = 開発者 | 公式サイト = 公式サイト | 公式マニュアル = 公式マニュアル | GitHubリポジトリ = GitHubリポジトリ | 使用技術 = 使用技術 }} 引数を省略した場合、タイトルはページ名が表示され、それ以外の項目は全て非表示になります。 <pre> {{TRPGツール概要 | 開発者 = | 公式サイト = | 公式マニュアル = | GitHubリポジトリ = | 使用技術 = }} </pre> <includeonly> <!--カテゴリは以下に追加してください--> {{デフォルトソート:TRPGつうるかいよう}} [[Category:概要テンプレート]] </includeonly> cf1d84a61c70469d6f59207a8b8ca2729af8a388 どどんとふ 0 10 102 100 2019-06-23T17:47:45Z Ochaochaocha3 1 脚注 wikitext text/x-wiki {{TRPGツール概要 | image = ファイル:dodontof-screenshot.png | キャプション = どどんとふのスクリーンショット | 開発者 = [https://twitter.com/torgtaitai たいたい竹流] | 公式サイト = [http://www.dodontof.com/ どどんとふ@えくすとり~む] | 公式マニュアル = [http://www.melonbooks.com/index.php?main_page=product_info&products_id=IT0000197863 どどんとふで始める初めてのオンラインセッション2017年夏の号!] | GitHubリポジトリ = [https://github.com/torgtaitai/DodontoF torgtaitai/DodontoF] | 使用技術 = [[Flash]]、[[Ruby]] }} '''どどんとふ'''は、[https://twitter.com/torgtaitai たいたい竹流氏]によって開発されているオンラインセッションツール。 == 概要 == オンラインセッションに必要な多くの機能を備えた、総合オンラインセッションツール。部屋の作成、チャット、ダイスボット、キャラクター管理、マップ管理、イニシアティブ表といった基本的な機能に加えて、以下のような豊富な機能を搭載している<ref name="official-manual">[http://www.melonbooks.com/index.php?main_page=product_info&products_id=IT0000197863 どどんとふで始める初めてのオンラインセッション2017年夏の号!]</ref>。 * 秘話チャット * シークレットダイス * ダイスシンボル * 共有メモ * カード * 資源管理 * 範囲 * 魔法タイマー * チット設置 * マップ手書き * 画像のアップロード * Webカメラ撮影 * 立ち絵 * ノベルゲーム風表示 * カットイン * 読み上げ * リプレイ録画 * 多言語対応 === ダイスボット === ダイスボットとして[[BCDice]](ボーンズ&カーズ)を使用している。現在のBCDiceは、どどんとふ環境で動作することを前提として開発、テストされている。様々なゲームシステムのダイスロールおよび表引きに加え、独自の表の追加、カード機能などBCDiceの機能をフル活用しているのは、どどんとふならではである。 == Flashの廃止に伴う影響 == どどんとふのクライアントプログラム(プレイヤーが操作する画面のプログラム)は、[[Flash]]を使用して作られている。Flashは2020年に廃止されることが決定しており、2021年以降、通常はブラウザからクライアントプログラムを動作させることができなくなる。そのため、[[どどんとふ公式鯖]]<ref>[https://twitter.com/DoDontoF_Srv/status/1112201807239901184 どどんとふ公式鯖とねこ卓公式鯖と氷丼公式鯖中の人さんのツイート: "2020年12月にどどんとふ公式鯖終了がかなり濃厚です。HTML5版を残すかは開発体制状況次第です。 Quoridornやねこ卓その他ツールは継続予定ですが、サーバー負荷は激減するけど収益も激減するのは確実なので、そこら辺をどうするかも課題です。無罪になったのにCoinhive無くなっちゃうしなあ。"]</ref>や[[どどんとふむせる]]<ref>[http://museru.blog.jp/archives/1066846255.html どどんとふ「むせる」の終了時期について : むせるいんふぉめーしょん]</ref>では、管理者が2020年にどどんとふの提供を終了することを宣言している。 なお、[[Ruby]]で書かれているどどんとふのサーバープログラムは、Flash廃止の影響を受けず、2021年以降も動作する。そのため、クライアントプログラムのみ[[HTML5]]で書き直す試みが行われている(kitt氏の[[HTML5版どどんとふ]])。HTML5版のクライアントが十分に動作するようになれば、2021年以降もどどんとふを使ってオンラインセッションを楽しむことができる可能性はある。 == 設置 == === 小規模サーバー === 以下の説明は公式マニュアル<ref name="official-manual" />を基にしている。 少人数で使用する場合は、[[Ruby]](1.8.7以上)が使えるレンタルサーバーにファイルを置き、パーミッションの設定をするだけでよい。マニュアルでは、さくらインターネットのレンタルサーバー([https://www.sakura.ne.jp/ さくらのレンタルサーバ])が推奨されている。 まず、公式サイトの[http://www.dodontof.com/index.php?option=com_content&view=article&id=246&Itemid=126 ダウンロードページ]から最新版または安定版のzipファイルをダウンロードし、展開する。さくらのレンタルサーバでアカウント名が「trpg_net」の場合、展開したファイルを以下のように配置し、パーミッションを設定する。 <pre> home +- trpg_net +- www | +- DodontoF (705) | | +- DodontoFServer.rb (705) | | +- log.txt (600) | | +- log.txt.0 (600) | | +- saveDataTempSpace (705) | | +- fileUploadSpace (705) | | +- replayDataUploadSpace (705) | +- imageUploadSpace (705) | +- smallImages (705) +- saveData (705) </pre> ファイルの配置およびパーミッション設定が完了したら、ブラウザから <code>DodontoF/DodontoFServer.rb</code> を開く。上記の例の場合、URLは <pre>http://trpg_net.sakura.ne.jp/DodontoF/DodontoFServer.rb</pre> となる。ファイルの配置およびパーミッション設定が正しくできていれば、以下のように表示される。 <syntaxhighlight lang="json"> ["「どどんとふ」の動作環境は正常に起動しています。"] </syntaxhighlight> 上記のメッセージが表示されたら、<code>DodontoF/DodontoF.swf</code> を開く。上記の例の場合、URLは <pre>http://trpg_net.sakura.ne.jp/DodontoF/DodontoF.swf</pre> となる。 === 大規模サーバー === レンタルサーバーを使う場合、快適に使用できる人数は10人程度までであり、それ以上の人数では負荷が重くなる。大規模なサーバーでは、以下のような構成とする例が多い。 * より高性能なサーバーやVPSを使う。 ** SSDを使う。 ** メモリに余裕があれば、RAMディスクを使う。 ** 必要に応じて、TCP/IPに関するLinuxカーネルのチューニングを行う。 * Webサーバーとしてnginxを使う。 * 最新のRubyを使う。 * FastCGIを使う。 ** spawn-fcgiなどでサーバープログラムを起動する。 ** Gem「fcgi」を使う。 * Gem「msgpack」を使う。 * 擬似cometモードを使わない。 設置の手順を解説している記事として、以下のものがある。 * [http://cre.jp/techblog/2016/01/27/dodontof-centos7-nginx-spawn/ クリエイターズネットワーク技術部ブログ » CentOS7+nginx+spawn-fcgi でどどんとふを動かす] ** [[TRPG.NET]]へのどどんとふの設置時の作業を基にしている。 * 大ちゃんのいろいろ雑記 - どどんとふをdebian+nginxで動かすやり方(nginxセットアップ編)@公式鯖3rdシリーズ ** [[どどんとふ公式鯖]]へのどどんとふ設置作業の記録。ハードウェアの性能を満たすのは難しいが、各要素は参考になる。 *# [https://www.taruki.com/wp/?p=6099 OS編] *# [https://www.taruki.com/wp/?p=6123 nginxセットアップ編] *# [https://www.taruki.com/wp/?p=6133 fcgi編] *# [https://www.taruki.com/wp/?p=6160 どどんとふ本体編] *# [https://www.taruki.com/wp/?p=6162 運用ツール編(最低限)] *# [https://www.taruki.com/wp/?p=6165 運用ツール編(その他)] *# [https://www.taruki.com/wp/?p=6182 運用ツール編(負荷グラフ)] == 脚注 == <references /> [[Category:TRPGツール]] {{DEFAULTSORT:ととんとふ}} 150bec60d263d1da6b2c91f5d0bcea6b1f11b875 BCDice 0 16 103 101 2019-06-23T17:49:24Z Ochaochaocha3 1 /* 概要 */ wikitext text/x-wiki {{TRPGツール概要 | 開発者 = ; Perl版 :[https://twitter.com/Faceless192x Faceless] ; Ruby版 :[https://twitter.com/torgtaitai たいたい竹流] | GitHubリポジトリ = [https://github.com/torgtaitai/BCDice torgtaitai/BCDice] | 使用技術 = [[Ruby]] }} '''BCDice'''(ボーンズ&カーズ)は、ダイスボットのひとつ。[[どどんとふ]]をはじめとした多くのTRPGツールに使用されている。現在は [https://twitter.com/torgtaitai たいたい竹流氏]を中心として開発が進められている。 == 概要 == 多くの日本製ゲームシステムに対応したダイスボット。[[どどんとふ]]をはじめとした多くのTRPGツールに使用されており、広く普及している。 Perlで書かれた[[IRC]]ボットとして[https://twitter.com/Faceless192x Faceless氏]によって開発され、[http://faceless-tools.cocolog-nifty.com/blog/2008/02/ver1015_2788.html 2008年に公開された]。その後、2011年に[https://twitter.com/torgtaitai たいたい竹流氏]によって[[Ruby]]に移植され、どどんとふへの対応が強化された。新しいゲームシステムに対応したダイスボットの開発や内部処理の改善などで、両氏以外にも多くの者が開発に参加している。 開発当初はIRCボットとしての使用が前提だったが、Rubyへの移植以来、ライブラリとしての使用が増えた。ライブラリとしては「どどんとふのダイスボット」という位置付けだったが、2016年に[[Onset!]]で採用され、その他のTRPGツールでも利用されるようになってきた。TRPGツールからのBCDiceの利用を容易にするために、HTTP経由での利用を可能とする[[BCDice-API]]も開発されている。BCDice-APIは現在[[どどんとふ公式鯖]]に設置されており、TRPGツールの開発において気軽にBCDiceを利用することができる。 == 関連項目 == * [[/TRPGツールからの呼び出し方]] [[Category:ダイスボット]] [[Category:BCDice|*BCDice]] 12a3f1328ef5d98b25e6fd9807a73e400c005807 117 103 2019-06-28T13:10:32Z Ochaochaocha3 1 /* 関連項目 */ wikitext text/x-wiki {{TRPGツール概要 | 開発者 = ; Perl版 :[https://twitter.com/Faceless192x Faceless] ; Ruby版 :[https://twitter.com/torgtaitai たいたい竹流] | GitHubリポジトリ = [https://github.com/torgtaitai/BCDice torgtaitai/BCDice] | 使用技術 = [[Ruby]] }} '''BCDice'''(ボーンズ&カーズ)は、ダイスボットのひとつ。[[どどんとふ]]をはじめとした多くのTRPGツールに使用されている。現在は [https://twitter.com/torgtaitai たいたい竹流氏]を中心として開発が進められている。 == 概要 == 多くの日本製ゲームシステムに対応したダイスボット。[[どどんとふ]]をはじめとした多くのTRPGツールに使用されており、広く普及している。 Perlで書かれた[[IRC]]ボットとして[https://twitter.com/Faceless192x Faceless氏]によって開発され、[http://faceless-tools.cocolog-nifty.com/blog/2008/02/ver1015_2788.html 2008年に公開された]。その後、2011年に[https://twitter.com/torgtaitai たいたい竹流氏]によって[[Ruby]]に移植され、どどんとふへの対応が強化された。新しいゲームシステムに対応したダイスボットの開発や内部処理の改善などで、両氏以外にも多くの者が開発に参加している。 開発当初はIRCボットとしての使用が前提だったが、Rubyへの移植以来、ライブラリとしての使用が増えた。ライブラリとしては「どどんとふのダイスボット」という位置付けだったが、2016年に[[Onset!]]で採用され、その他のTRPGツールでも利用されるようになってきた。TRPGツールからのBCDiceの利用を容易にするために、HTTP経由での利用を可能とする[[BCDice-API]]も開発されている。BCDice-APIは現在[[どどんとふ公式鯖]]に設置されており、TRPGツールの開発において気軽にBCDiceを利用することができる。 == 関連項目 == * [[/TRPGツールからの呼び出し方]] * [[/内部処理]] [[Category:ダイスボット]] [[Category:BCDice|*BCDice]] 3f7f79c72812cb0d56232d997c5b3f6bee50d14b 157 117 2020-07-07T07:04:20Z Koi-chan 3 wikitext text/x-wiki {{TRPGツール概要 | 開発者 = ; Perl版 :[https://twitter.com/Faceless192x Faceless] ; Ruby版 :[https://twitter.com/torgtaitai たいたい竹流] ; v3 :[https://twitter.com/ysakasin 酒田 シンジ]等 | 公式サイト = [https://bcdice.org BCDice] | GitHubリポジトリ = [https://github.com/bcdice/BCDice bcdice/BCDice] | 使用技術 = [[Ruby]] }} '''BCDice'''(ボーンズ&カーズ)は、ダイスボットのひとつ。[[どどんとふ]]をはじめとした多くのTRPGツールに使用されている。現在は 現在は[https://twitter.com/ysakasin 酒田 シンジ]を中心として、開発が進められている。 == 概要 == 多くの日本製ゲームシステムに対応したダイスボット。[[どどんとふ]]をはじめとした多くのTRPGツールに使用されており、広く普及している。 Perlで書かれた[[IRC]]ボットとして[https://twitter.com/Faceless192x Faceless氏]によって開発され、[http://faceless-tools.cocolog-nifty.com/blog/2008/02/ver1015_2788.html 2008年に公開された]。その後、2011年に[https://twitter.com/torgtaitai たいたい竹流氏]によって[[Ruby]]に移植され、どどんとふへの対応が強化された。2020年、Flashの終了に伴い[[どどんとふ]]の開発終了が宣言された後、[https://twitter.com/ysakasin 酒田 シンジ]氏がメンテナンスを引き継ぎ、現在はコミュニティベースでの開発が行なわれている。その他にも、新しいゲームシステムに対応したダイスボットの開発や内部処理の改善などで、両氏以外にも多くの者が開発に参加している。 開発当初はIRCボットとしての使用が前提だったが、Rubyへの移植以来、ライブラリとしての使用が増えた。ライブラリとしては「どどんとふのダイスボット」という位置付けだったが、2016年に[[Onset!]]で採用され、その他のTRPGツールでも利用されるようになってきた。TRPGツールからのBCDiceの利用を容易にするために、HTTP経由での利用を可能とする[[BCDice-API]]も開発されている。BCDice-APIは現在[[どどんとふ公式鯖]]などに設置されており、TRPGツールの開発において気軽にBCDiceを利用することができる。 == 関連項目 == * [[/TRPGツールからの呼び出し方]] * [[/内部処理]] [[Category:ダイスボット]] [[Category:BCDice|*BCDice]] 68cab3c5c8e04ef223fbe3446b4c0dc92cb8162c 160 157 2020-07-07T07:09:15Z Koi-chan 3 wikitext text/x-wiki {{TRPGツール概要 | 開発者 = ; Perl版 :[https://twitter.com/Faceless192x Faceless] ; Ruby版 :[https://twitter.com/torgtaitai たいたい竹流] ; v3 :[https://twitter.com/ysakasin 酒田 シンジ]等 | 公式サイト = [https://bcdice.org BCDice] | GitHubリポジトリ = [https://github.com/bcdice/BCDice bcdice/BCDice] | 使用技術 = [[Ruby]] }} '''BCDice'''(ボーンズ&カーズ)は、ダイスボットのひとつ。[[どどんとふ]]をはじめとした多くのTRPGツールに使用されている。現在は 現在は[https://twitter.com/ysakasin 酒田 シンジ]を中心として、開発が進められている。 == 概要 == 多くの日本製ゲームシステムに対応したダイスボット。[[どどんとふ]]をはじめとした多くのTRPGツールに使用されており、広く普及している。 開発当初はIRCボットとしての使用が前提だったが、Rubyへの移植以来、ライブラリとしての使用が増えた。ライブラリとしては「どどんとふのダイスボット」という位置付けだったが、2016年に[[Onset!]]で採用され、その他のTRPGツールでも利用されるようになってきた。 TRPGツールからのBCDiceの利用を容易にするために、HTTP経由での利用を可能とする[[BCDice-API]]も開発されている。BCDice-APIは現在[[どどんとふ公式鯖]]などに設置されており、TRPGツールの開発において気軽にBCDiceを利用することができる。 その他にも、新しいゲームシステムに対応したダイスボットの開発や内部処理の改善などで、多くの者が開発に参加している。 == 歴史 == Perlで書かれた[[IRC]]ボットとして[https://twitter.com/Faceless192x Faceless氏]によって開発され、[http://faceless-tools.cocolog-nifty.com/blog/2008/02/ver1015_2788.html 2008年に公開された]。 その後、2011年に[https://twitter.com/torgtaitai たいたい竹流氏]によって[[Ruby]]に移植され、どどんとふへの対応が強化された。 2020年、Flashの終了に伴い[[どどんとふ]]の開発終了が宣言された後、[https://twitter.com/ysakasin 酒田 シンジ]氏がメンテナンスを引き継ぎ、現在はコミュニティベースでの開発が行なわれている。 == 関連項目 == * [[/TRPGツールからの呼び出し方]] * [[/内部処理]] [[Category:ダイスボット]] [[Category:BCDice|*BCDice]] f894634123e616550bd8faa658e48397fb9bb445 IRC 0 14 104 49 2019-06-23T17:54:38Z Ochaochaocha3 1 /* TRPGのオンラインセッションにおけるIRCの利用 */ wikitext text/x-wiki '''IRC'''(Internet Relay Chat)は、チャットプロトコルのひとつ。1990年代からTRPGのオンラインセッションに利用されている。 == 概要 == 古くからある高速、軽快なチャットプロトコル。1988年にフィンランドのプログラマJarkko Oikarinenによって開発された<ref>[http://www.irc.org/history_docs/jarkko.html IRC History by Jarkko Oikarinen - IRC.org]</ref>。[[Skype]]や[[Discord]]などが普及する以前は、チャットにおける事実上の標準プロトコルだった<ref>[http://hiki.trpg.net/wiki/?IRC 旧TRPG.NET Wiki - IRC]</ref>。 IRCによるチャットを行うには、クライアントソフトウェア(クライアント)と呼ばれる専用のプログラムを使う。用意されたサーバへクライアントを使用して接続することで、多くのユーザがほぼリアルタイムの会話を行える。IRCはあくまでプロトコルであるため、クライアントが対応していれば、PCやタブレット端末、スマートフォンといった様々な種類の端末からチャットに参加できる。また、クライアントには多くの種類があり、ユーザが好みのものを使うことができる。 == TRPGのオンラインセッションにおけるIRCの利用 == 2000年代前半まではチャットにおける事実上の標準プロトコルだったため、TRPGのオンラインセッションにIRCがよく利用されていた。より高機能なチャットプラットフォームが普及した現在も廃れてはおらず、一定数の利用者がいる。基本的には文章のみでセッションを進めることになるが、アップロードした画像のURLを送信する、[[ダイスボット]]というダイスロールを模倣するプログラムを利用するなどの方法により、より多くの情報を導入することができる。 日本では、1990年代後半に[[TRPG.NET]]がIRCネットワークirc.trpg.net系の運用を開始し、このIRCネットワークがオンラインセッションに多く利用されてきた。irc.trpg.net系は、現在[[irc.cre.jp系]]として運用されている。 == 規格 == 1993年に、Jarkko Oikarinenが[https://tools.ietf.org/html/rfc1459 RFC 1459]([http://web.archive.org/web/20111228003516/http://www.haun.org/kent/lib/rfc1459-irc-ja.html 日本語訳のアーカイブ])を発表した。このRFCに準拠するように、サーバソフトウェアやクライアントソフトウェアが実装されてきた。 2000年には、Christophe Kaltが以下の4つのRFCを発表した。 * [https://tools.ietf.org/html/rfc2810 RFC 2810]([http://web.archive.org/web/20070705011756/http://www.alt-r.com/lib/rfc2810j.html 日本語訳のアーカイブ]):アーキテクチャ * [https://tools.ietf.org/html/rfc2811 RFC 2811]([http://web.archive.org/web/20070403224951/http://www.alt-r.com/lib/rfc2811j.html 日本語訳のアーカイブ]):チャンネル管理 * [https://tools.ietf.org/html/rfc2812 RFC 2812]([http://web.archive.org/web/20070701072918/http://www.alt-r.com/lib/rfc2812j.html 日本語訳のアーカイブ]):クライアントプロトコル * [https://tools.ietf.org/html/rfc2813 RFC 2813]([http://web.archive.org/web/20070617180733/http://www.alt-r.com/lib/rfc2813j.html 日本語訳のアーカイブ]):サーバプロトコル 2014年には、Richard Hartmannが[https://tools.ietf.org/html/rfc7194 RFC 7194]を発表した。このRFCでは、TLS/SSLを利用してIRCの通信を暗号化する「ircs-u」の内容が述べられている。 == 脚注 == <references /> [[Category:チャット]] d8ba7405b6bf00db87b9c96a7790392520ff8f8f 135 104 2019-07-02T14:43:30Z Koi-chan 3 wikitext text/x-wiki '''IRC'''(Internet Relay Chat)は、チャットプロトコルのひとつ。1990年代からTRPGのオンラインセッションに利用されている。 == 概要 == 古くからある高速、軽快なチャットプロトコル。1988年にフィンランドのプログラマJarkko Oikarinenによって開発された<ref>[http://www.irc.org/history_docs/jarkko.html IRC History by Jarkko Oikarinen - IRC.org]</ref>。[[Skype]]や[[Discord]]などが普及する以前は、チャットにおける事実上の標準プロトコルだった<ref>[http://hiki.trpg.net/wiki/?IRC 旧TRPG.NET Wiki - IRC]</ref>。 IRCによるチャットを行うには、クライアントソフトウェア(クライアント)と呼ばれる専用のプログラムを使う。用意されたサーバへクライアントを使用して接続することで、多くのユーザがほぼリアルタイムの会話を行える。IRCはあくまでプロトコルであるため、クライアントが対応していれば、PCやタブレット端末、スマートフォンといった様々な種類の端末からチャットに参加できる。また、クライアントには多くの種類があり、ユーザが好みのものを使うことができる。 == TRPGのオンラインセッションにおけるIRCの利用 == 2000年代前半まではチャットにおける事実上の標準プロトコルだったため、TRPGのオンラインセッションにIRCがよく利用されていた。より高機能なチャットプラットフォームが普及した現在も廃れてはおらず、一定数の利用者がいる。基本的には文章のみでセッションを進めることになるが、アップロードした画像のURLを送信する、[[ダイスボット]]というダイスロールを模倣するプログラムを利用するなどの方法により、より多くの情報を導入することができる。 日本では、1990年代後半に[[TRPG.NET]]がIRCネットワークirc.trpg.net系の運用を開始し、このIRCネットワークがオンラインセッションに多く利用されてきた。irc.trpg.net系は、現在[[irc.cre.jp系]]として運用されている。 == 規格 == 1993年に、Jarkko Oikarinenが[https://tools.ietf.org/html/rfc1459 RFC 1459]([http://web.archive.org/web/20111228003516/http://www.haun.org/kent/lib/rfc1459-irc-ja.html 日本語訳のアーカイブ])を発表した。このRFCに準拠するように、サーバソフトウェアやクライアントソフトウェアが実装されてきた。 2000年には、Christophe Kaltが以下の4つのRFCを発表した。 * [https://tools.ietf.org/html/rfc2810 RFC 2810]([http://web.archive.org/web/20070705011756/http://www.alt-r.com/lib/rfc2810j.html 日本語訳のアーカイブ]):アーキテクチャ * [https://tools.ietf.org/html/rfc2811 RFC 2811]([http://web.archive.org/web/20070403224951/http://www.alt-r.com/lib/rfc2811j.html 日本語訳のアーカイブ]):チャンネル管理 * [https://tools.ietf.org/html/rfc2812 RFC 2812]([http://web.archive.org/web/20070701072918/http://www.alt-r.com/lib/rfc2812j.html 日本語訳のアーカイブ]):クライアントプロトコル * [https://tools.ietf.org/html/rfc2813 RFC 2813]([http://web.archive.org/web/20070617180733/http://www.alt-r.com/lib/rfc2813j.html 日本語訳のアーカイブ]):サーバプロトコル 2014年には、Richard Hartmannが[https://tools.ietf.org/html/rfc7194 RFC 7194]を発表した。このRFCでは、TLS/SSLを利用してIRCの通信を暗号化する「ircs-u」の内容が述べられている。 現在、[https://ircv3.net IRCv3 Working Group]が、より現代的なプロトコルにしようと作業を進めている。 == 脚注 == <references /> [[Category:チャット]] 0aef4c3403478d085352725865a0d80004dba9aa 136 135 2019-07-02T14:43:54Z Koi-chan 3 /* 規格 */ wikitext text/x-wiki '''IRC'''(Internet Relay Chat)は、チャットプロトコルのひとつ。1990年代からTRPGのオンラインセッションに利用されている。 == 概要 == 古くからある高速、軽快なチャットプロトコル。1988年にフィンランドのプログラマJarkko Oikarinenによって開発された<ref>[http://www.irc.org/history_docs/jarkko.html IRC History by Jarkko Oikarinen - IRC.org]</ref>。[[Skype]]や[[Discord]]などが普及する以前は、チャットにおける事実上の標準プロトコルだった<ref>[http://hiki.trpg.net/wiki/?IRC 旧TRPG.NET Wiki - IRC]</ref>。 IRCによるチャットを行うには、クライアントソフトウェア(クライアント)と呼ばれる専用のプログラムを使う。用意されたサーバへクライアントを使用して接続することで、多くのユーザがほぼリアルタイムの会話を行える。IRCはあくまでプロトコルであるため、クライアントが対応していれば、PCやタブレット端末、スマートフォンといった様々な種類の端末からチャットに参加できる。また、クライアントには多くの種類があり、ユーザが好みのものを使うことができる。 == TRPGのオンラインセッションにおけるIRCの利用 == 2000年代前半まではチャットにおける事実上の標準プロトコルだったため、TRPGのオンラインセッションにIRCがよく利用されていた。より高機能なチャットプラットフォームが普及した現在も廃れてはおらず、一定数の利用者がいる。基本的には文章のみでセッションを進めることになるが、アップロードした画像のURLを送信する、[[ダイスボット]]というダイスロールを模倣するプログラムを利用するなどの方法により、より多くの情報を導入することができる。 日本では、1990年代後半に[[TRPG.NET]]がIRCネットワークirc.trpg.net系の運用を開始し、このIRCネットワークがオンラインセッションに多く利用されてきた。irc.trpg.net系は、現在[[irc.cre.jp系]]として運用されている。 == 規格 == 1993年に、Jarkko Oikarinenが[https://tools.ietf.org/html/rfc1459 RFC 1459]([http://web.archive.org/web/20111228003516/http://www.haun.org/kent/lib/rfc1459-irc-ja.html 日本語訳のアーカイブ])を発表した。このRFCに準拠するように、サーバソフトウェアやクライアントソフトウェアが実装されてきた。 2000年には、Christophe Kaltが以下の4つのRFCを発表した。 * [https://tools.ietf.org/html/rfc2810 RFC 2810]([http://web.archive.org/web/20070705011756/http://www.alt-r.com/lib/rfc2810j.html 日本語訳のアーカイブ]):アーキテクチャ * [https://tools.ietf.org/html/rfc2811 RFC 2811]([http://web.archive.org/web/20070403224951/http://www.alt-r.com/lib/rfc2811j.html 日本語訳のアーカイブ]):チャンネル管理 * [https://tools.ietf.org/html/rfc2812 RFC 2812]([http://web.archive.org/web/20070701072918/http://www.alt-r.com/lib/rfc2812j.html 日本語訳のアーカイブ]):クライアントプロトコル * [https://tools.ietf.org/html/rfc2813 RFC 2813]([http://web.archive.org/web/20070617180733/http://www.alt-r.com/lib/rfc2813j.html 日本語訳のアーカイブ]):サーバプロトコル 2014年には、Richard Hartmannが[https://tools.ietf.org/html/rfc7194 RFC 7194]を発表した。このRFCでは、TLS/SSLを利用してIRCの通信を暗号化する「ircs-u」の内容が述べられている。 2019年現在、[https://ircv3.net IRCv3 Working Group]が、より現代的なプロトコルにしようと作業を進めている。 == 脚注 == <references /> [[Category:チャット]] 9e5ed2ae6c07b59002a869c46226ee5242e18d3b 142 136 2019-07-05T14:13:42Z Ochaochaocha3 1 カテゴリを追加する wikitext text/x-wiki '''IRC'''(Internet Relay Chat)は、チャットプロトコルのひとつ。1990年代からTRPGのオンラインセッションに利用されている。 == 概要 == 古くからある高速、軽快なチャットプロトコル。1988年にフィンランドのプログラマJarkko Oikarinenによって開発された<ref>[http://www.irc.org/history_docs/jarkko.html IRC History by Jarkko Oikarinen - IRC.org]</ref>。[[Skype]]や[[Discord]]などが普及する以前は、チャットにおける事実上の標準プロトコルだった<ref>[http://hiki.trpg.net/wiki/?IRC 旧TRPG.NET Wiki - IRC]</ref>。 IRCによるチャットを行うには、クライアントソフトウェア(クライアント)と呼ばれる専用のプログラムを使う。用意されたサーバへクライアントを使用して接続することで、多くのユーザがほぼリアルタイムの会話を行える。IRCはあくまでプロトコルであるため、クライアントが対応していれば、PCやタブレット端末、スマートフォンといった様々な種類の端末からチャットに参加できる。また、クライアントには多くの種類があり、ユーザが好みのものを使うことができる。 == TRPGのオンラインセッションにおけるIRCの利用 == 2000年代前半まではチャットにおける事実上の標準プロトコルだったため、TRPGのオンラインセッションにIRCがよく利用されていた。より高機能なチャットプラットフォームが普及した現在も廃れてはおらず、一定数の利用者がいる。基本的には文章のみでセッションを進めることになるが、アップロードした画像のURLを送信する、[[ダイスボット]]というダイスロールを模倣するプログラムを利用するなどの方法により、より多くの情報を導入することができる。 日本では、1990年代後半に[[TRPG.NET]]がIRCネットワークirc.trpg.net系の運用を開始し、このIRCネットワークがオンラインセッションに多く利用されてきた。irc.trpg.net系は、現在[[irc.cre.jp系]]として運用されている。 == 規格 == 1993年に、Jarkko Oikarinenが[https://tools.ietf.org/html/rfc1459 RFC 1459]([http://web.archive.org/web/20111228003516/http://www.haun.org/kent/lib/rfc1459-irc-ja.html 日本語訳のアーカイブ])を発表した。このRFCに準拠するように、サーバソフトウェアやクライアントソフトウェアが実装されてきた。 2000年には、Christophe Kaltが以下の4つのRFCを発表した。 * [https://tools.ietf.org/html/rfc2810 RFC 2810]([http://web.archive.org/web/20070705011756/http://www.alt-r.com/lib/rfc2810j.html 日本語訳のアーカイブ]):アーキテクチャ * [https://tools.ietf.org/html/rfc2811 RFC 2811]([http://web.archive.org/web/20070403224951/http://www.alt-r.com/lib/rfc2811j.html 日本語訳のアーカイブ]):チャンネル管理 * [https://tools.ietf.org/html/rfc2812 RFC 2812]([http://web.archive.org/web/20070701072918/http://www.alt-r.com/lib/rfc2812j.html 日本語訳のアーカイブ]):クライアントプロトコル * [https://tools.ietf.org/html/rfc2813 RFC 2813]([http://web.archive.org/web/20070617180733/http://www.alt-r.com/lib/rfc2813j.html 日本語訳のアーカイブ]):サーバプロトコル 2014年には、Richard Hartmannが[https://tools.ietf.org/html/rfc7194 RFC 7194]を発表した。このRFCでは、TLS/SSLを利用してIRCの通信を暗号化する「ircs-u」の内容が述べられている。 2019年現在、[https://ircv3.net IRCv3 Working Group]が、より現代的なプロトコルにしようと作業を進めている。 == 脚注 == <references /> [[Category:チャット]] [[Category:IRC|*IRC]] 63975890adb677b4640d51ff10925b095e8cee20 BCDice/TRPGツールからの呼び出し方/どどんとふ 0 23 105 48 2019-06-24T18:00:12Z Ochaochaocha3 1 DiceAdapterについて追記する wikitext text/x-wiki [[どどんとふ]]からの[[BCDice]]の呼び出し方。このページでは、Rubyで書かれたどどんとふのサーバのダイス関連の処理を扱う。[https://github.com/torgtaitai/DodontoF/tree/d3e4cc374885986efc761cfabbb19e4b35e815e0 v1.49.04.01]のソースコードを参考にしている。 == 各ファイルの役割 == どどんとふのサーバでは、ダイスボットとの通信の処理は以下のファイルに記述されている。 * [https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb src_ruby/dodontof/dice_adapter.rb]:BCDiceとのアダプタ * [https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/diceBotInfos.rb src_ruby/diceBotInfos.rb]:ダイスボットの情報を取得する処理 * [https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb DodontoFServer.rb]:サーバ本体 == src_ruby/dodontof/dice_adapter.rb:BCDiceとのアダプタ == https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb ダイスロールと関係していることがすぐに分かるファイル名だが、実はほとんど独自の表からの情報の読み出しやファイル管理の処理となっている。 === L7-L10:<code>DiceAdapter#initialize</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L7-L10 アダプタを初期化する。 * <code>@dir</code>:部屋固有のデータ保存ディレクトリが設定される。詳細は「[[#L164-L185:@dice_adapter の初期化]]」で解説する。 * <code>@diceBotTablePrefix</code>:必ず <code>'diceBotTable_'</code> が設定される。 <syntaxhighlight lang="ruby"> def initialize(dir, prefix) @logger = DodontoF::Logger.instance @dir = dir @diceBotTablePrefix = prefix end </syntaxhighlight> === L13-L34:<code>DiceAdapter#rollDice</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L13-L34 ダイスロールを行う。メッセージ、ゲームシステム、出目を返すかが指定できる。結果のメッセージ、シークレットダイスかどうか、出目が返る。結果のメッセージの <code>'>'</code> は <code>'→'</code> に置換され、末尾の改行コードは削除される。 <syntaxhighlight lang="ruby"> def rollDice(params) require 'cgiDiceBot.rb' message = params['message'] gameType = params['gameType'] isNeedResult = params['isNeedResult'] @logger.debug(message, 'rollDice message') @logger.debug(gameType, 'rollDice gameType') bot = CgiDiceBot.new result, randResults = bot.roll(message, gameType, @dir, @diceBotTablePrefix, isNeedResult) result.gsub!(/>/, '→') result.sub!(/\r?\n?\Z/m, '') @logger.debug(result, 'rollDice result') @logger.debug(randResults, 'rollDice randResults') return result, bot.isSecret, randResults end </syntaxhighlight> === L36-L45:<code>DiceAdapter#getGameCommandInfos</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L36-L45 独自の表について、ゲームタイプ(ゲームの識別子)および含まれるコマンドの情報を返す。<code>CgiDiceBot#getGameCommandInfos</code> を経由して <code>TableFileData#getGameCommandInfos</code> を呼び出している。 <syntaxhighlight lang="ruby"> def getGameCommandInfos require 'cgiDiceBot.rb' bot = CgiDiceBot.new @logger.debug(@dir, 'dir') commandInfos = bot.getGameCommandInfos(@dir, @diceBotTablePrefix) @logger.debug(commandInfos, "getGameCommandInfos End commandInfos") return commandInfos end </syntaxhighlight> === L47-L63:<code>DiceAdapter#getBotTableInfosFromDir</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L47-L63 独自の表についての情報を取得する。<code>getGameCommandInfos</code> と似ているが、こちらの方が返される情報が詳しい? <syntaxhighlight lang="ruby"> def getBotTableInfosFromDir @logger.debug(@dir, 'getBotTableInfosFromDir dir') require 'TableFileData' isLoadCommonTable = false tableFileData = TableFileData.new( isLoadCommonTable ) tableFileData.setDir(@dir, @diceBotTablePrefix) tableInfos = tableFileData.getAllTableInfo @logger.debug(tableInfos, "getBotTableInfosFromDir tableInfos") tableInfos.sort!{|a, b| a["command"].to_i <=> b["command"].to_i} @logger.debug(tableInfos, 'getBotTableInfosFromDir result tableInfos') return tableInfos end </syntaxhighlight> === L65-L84:<code>DiceAdapter#addBotTableMain</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L65-L84 独自の表のファイルを保存する。 <syntaxhighlight lang="ruby"> def addBotTableMain(params) @logger.debug("addBotTableMain Begin") DodontoF::Utils.makeDir(@dir) require 'TableFileData' resultText = 'OK' begin creator = TableFileCreator.new(@dir, @diceBotTablePrefix, params) creator.execute rescue Exception => e @logger.exception(e) resultText = getLanguageKey( e.to_s ) end @logger.debug(resultText, "addBotTableMain End resultText") return resultText end </syntaxhighlight> === L86-L103:<code>DiceAdapter#changeBotTableMain</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L86-L103 独自の表のファイルを更新する。 <syntaxhighlight lang="ruby"> def changeBotTableMain(params) @logger.debug("changeBotTableMain Begin") require 'TableFileData' resultText = 'OK' begin creator = TableFileEditer.new(@dir, @diceBotTablePrefix, params) creator.execute rescue Exception => e @logger.exception(e) resultText = getLanguageKey( e.to_s ) end @logger.debug(resultText, "changeBotTableMain End resultText") return resultText end </syntaxhighlight> === L105-L135:<code>DiceAdapter#removeBotTableMain</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L86-L103 独自の表のファイルを削除する。 <syntaxhighlight lang="ruby"> def removeBotTableMain(params) @logger.debug("removeBotTableMain Begin") command = params["command"] require 'TableFileData' isLoadCommonTable = false tableFileData = TableFileData.new( isLoadCommonTable ) tableFileData.setDir(@dir, @diceBotTablePrefix) tableInfos = tableFileData.getAllTableInfo tableInfo = tableInfos.find{|i| i["command"] == command} @logger.debug(tableInfo, "tableInfo") return if( tableInfo.nil? ) fileName = tableInfo["fileName"] @logger.debug(fileName, "fileName") return if( fileName.nil? ) @logger.debug("isFile exist?") return unless( File.exist?(fileName) ) begin File.delete(fileName) rescue Exception => e @logger.exception(e) end @logger.debug("removeBotTableMain End") end </syntaxhighlight> == src_ruby/diceBotInfos.rb:ダイスボットの情報を取得する処理 == https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/diceBotInfos.rb === L69-L102:<code>DiceBotInfos.get</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/diceBotInfos.rb#L69-L102 <syntaxhighlight lang="ruby"> # ダイスボットの情報の一覧を取得する # @param [Array<String>] orderedGameNames 順序付けられたゲーム名の配列 # @param [Boolean] showAllDiceBots すべてのダイスボットを表示するか # @return [Array<Hash>] def self.get(orderedGameNames, showAllDiceBots) diceBots = DiceBotLoader.collectDiceBots # ゲーム名 => ダイスボットの対応を作る diceBotFor = Hash[ diceBots.map { |diceBot| [diceBot.gameName, diceBot] } ] toDiceBot = lambda { |gameName| diceBotFor[gameName] } orderedEnabledDiceBots = orderedGameNames. map(&toDiceBot). # ゲーム名が誤記されていた場合nilになるので除く compact orderedDiceBots = if showAllDiceBots disabledGameNames = diceBotFor.keys - orderedGameNames orderedDisabledDiceBots = disabledGameNames. sort. map(&toDiceBot) # 一覧に記載されていたゲーム→記載されていなかったゲームの順 orderedEnabledDiceBots + orderedDisabledDiceBots else orderedEnabledDiceBots end # 指定なし→各ゲーム→基本の順で返す [NONE_DICE_BOT_INFO] + orderedDiceBots.map(&:info) + [BASE_DICE_BOT_INFO] end </syntaxhighlight> === L104-150:<code>DiceBotInfos.withTableCommands</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/diceBotInfos.rb#L104-150 <syntaxhighlight lang="ruby"> # テーブルのコマンドも加えたダイスボットの情報の一覧を取得する # @param [Array<String>] orderedGameNames 順序付けられたゲーム名の配列 # @param [Boolean] showAllDiceBots すべてのダイスボットを表示するか # @param [Array<Hash>] commandInfos テーブルのコマンドの情報の配列 # @return [Array<Hash>] # # このメソッドは、ダイスボットから返された情報を破壊しない。 def self.withTableCommands(orderedGameNames, showAllDiceBots, commandInfos) diceBotInfos = self.get(orderedGameNames, showAllDiceBots) # ゲームタイプ => ダイスボット情報のインデックスの対応を作る diceBotInfoIndexFor = Hash[ diceBotInfos.each_with_index.map { |info, i| [info[KEY_GAME_TYPE], i] } ] allGameTypes = diceBotInfoIndexFor.keys # ゲームタイプ => 追加するコマンドの一覧の対応を作る commandsToAdd = commandInfos.reduce({}) { |acc, commandInfo| gameType = commandInfo[KEY_GAME_TYPE] command = commandInfo[KEY_COMMAND] # ゲームタイプ未指定ならすべてのゲームタイプに追加する targetGameTypes = gameType.empty? ? allGameTypes : [gameType] targetGameTypes.each do |targetGameType| acc[targetGameType] ||= [] acc[targetGameType] << command end acc } commandsToAdd.each do |gameType, commands| diceBotInfoIndex = diceBotInfoIndexFor[gameType] next unless diceBotInfoIndex originalInfo = diceBotInfos[diceBotInfoIndex] # ダイスボットから返された情報を破壊しないようにして更新する diceBotInfos[diceBotInfoIndex] = originalInfo.merge({ KEY_PREFIXS => originalInfo[KEY_PREFIXS] + commands }) end diceBotInfos end </syntaxhighlight> == DodontoFServer.rb:サーバ本体 == https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb === L164-L185:<code>@dice_adapter</code> の初期化 === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L164-L185 <syntaxhighlight lang="ruby"> def initialize(saveDirInfo, cgiParams) @cgiParams = cgiParams @saveDirInfo = saveDirInfo @logger = DodontoF::Logger.instance @cgi = nil @jsonpCallBack = nil @isWebIf = false @isRecordEmpty = false initSaveFiles(getRequestData('room')) @dice_adapter = DodontoF::DiceAdapter.new(getDiceBotExtraTableDirName, 'diceBotTable_') @fullBackupFileBaseName = "DodontoFFullBackup" @allSaveDataFileExt = '.tar.gz' @defaultAllSaveData = 'default.sav' @defaultChatPallete = 'default.cpd' @card = nil end </syntaxhighlight> <code>getDiceBotExtraTableDirName</code>([https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3727-L3729 L3727-L3729])では、<code>getRoomLocalSpaceDirName</code>([https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3262-L3265 L3262-L3265])、<code>getRoomLocalSpaceDirNameByRoomNo</code>([https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3267-L3273 L3267-L3273])を経由して、<code>$imageUploadDir</code> の中の部屋固有のディレクトリを返す。 === L1193-L1210:<code>getWebIfServerInfo</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L1193-L1210 Webインターフェースのサーバ情報を返すコマンド。<code>getDiceBotInfos</code> でダイスボットの情報を取得する。 <syntaxhighlight lang="ruby"> def getWebIfServerInfo() jsonData = { "maxRoom" => ($saveDataMaxCount - 1), 'isNeedCreatePassword' => (not $createPlayRoomPassword.empty?), 'result' => 'OK', } if( getWebIfRequestBoolean("card", false) ) cardInfos = getCardsInfo.collectCardTypeAndTypeName($cardOrder) jsonData["cardInfos"] = cardInfos end if( getWebIfRequestBoolean("dice", false) ) jsonData['diceBotInfos'] = getDiceBotInfos() end return jsonData end </syntaxhighlight> === L2090:<code>getLoginInfo</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2090 ダイスボット情報の取得を行う。 <syntaxhighlight lang="ruby"> diceBotInfos = getDiceBotInfos() </syntaxhighlight> === L2266-L2280:<code>getDiceBotInfos</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2266-L2280 ダイスボット情報取得処理の実装。部屋に入っているかどうかで、テーブルのコマンドも含めた情報を返すかどうかを決定している。 <syntaxhighlight lang="ruby"> def getDiceBotInfos @logger.debug("getDiceBotInfos() Begin") require 'diceBotInfos' orderedGameNames = $diceBotOrder.split("\n") if @saveDirInfo.getSaveDataDirIndex != -1 DiceBotInfos.withTableCommands(orderedGameNames, $isDisplayAllDice, @dice_adapter.getGameCommandInfos) else DiceBotInfos.get(orderedGameNames, $isDisplayAllDice) end end </syntaxhighlight> === L2542-2556:<code>save</code>, <code>getDiceTableData</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2542-2556 部屋のデータの保存時に、独自の表についての情報を取得する。 <syntaxhighlight lang="ruby"> def save() isAddPlayRoomInfo = true extension = @@saveFileExtension addInfos = {} addInfos[$diceBotTableSaveKey] = getDiceTableData() saveSelectFiles($saveFiles.keys, extension, isAddPlayRoomInfo, addInfos) end def getDiceTableData() tableInfos = @dice_adapter.getBotTableInfosFromDir tableInfos.each{|i| i.delete('fileName') } return tableInfos end </syntaxhighlight> === L2806-L2817:<code>getBotTableInfos</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2806-L2817 独自の表についての情報を取得する。 <syntaxhighlight lang="ruby"> def getBotTableInfos() @logger.debug("getBotTableInfos Begin") result = { "resultText"=> "OK", } result["tableInfos"] = @dice_adapter.getBotTableInfosFromDir @logger.debug(result, "result") @logger.debug("getBotTableInfos End") return result end </syntaxhighlight> === L2819-L2835:<code>addBotTable</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2819-L2835 独自の表を追加する。 <syntaxhighlight lang="ruby"> def addBotTable() result = {} params = getParamsFromRequestData() result['resultText'] = @dice_adapter.addBotTableMain(params) if( result['resultText'] != "OK" ) return result end @logger.debug("addBotTableMain called") result = getBotTableInfos() @logger.debug(result, "addBotTable result") return result end </syntaxhighlight> === L2837-L2849:<code>changeBotTable</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2837-L2849 独自の表を変更する。 <syntaxhighlight lang="ruby"> def changeBotTable() params = getParamsFromRequestData() result = {} result['resultText'] = @dice_adapter.changeBotTableMain(params) if( result['resultText'] != "OK" ) return result end result = getBotTableInfos() return result end </syntaxhighlight> === L2851-L2855:<code>removeBotTable</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2851-L2855 独自の表を削除する。 <syntaxhighlight lang="ruby"> def removeBotTable() params = getParamsFromRequestData() @dice_adapter.removeBotTableMain(params) return getBotTableInfos() end </syntaxhighlight> === L3458-L3459:<code>loadSaveFileDataFilterByTargets</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3458-L3459 セーブデータの部分読み込み処理の一部。独自の表を読み込む。 <syntaxhighlight lang="ruby"> when "diceBotTable" loadDiceBotTable(jsonData) </syntaxhighlight> === L3511-L3531:<code>loadDiceBotTable</code>, <code>getDiceBotTableString</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3511-L3531 独自の表を読み込む。 <syntaxhighlight lang="ruby"> def loadDiceBotTable(jsonData) data = jsonData[$diceBotTableSaveKey] return if( data.nil? ) data.each do |info| info['table'] = getDiceBotTableString(info['table']) @dice_adapter.addBotTableMain(info) end end def getDiceBotTableString(table) lines = [] table.each do |line| lines << line.join(":") end return lines.join("\n") end </syntaxhighlight> === L3632-L3657:<code>sendDiceBotChatMessage</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3632-L3657 BCDiceにコマンドを送る処理。<code>回数 コマンド</code> という形で送信回数が指定されていた場合は、指定された回数だけコマンドをBCDiceに送る。 <syntaxhighlight lang="ruby"> def sendDiceBotChatMessage @logger.debug('sendDiceBotChatMessage') params = getParamsFromRequestData() repeatCount = getDiceBotRepeatCount(params) results = [] repeatCount.times do |i| paramsClone = params.clone paramsClone['message'] += " \##{ i + 1 }" if( repeatCount > 1 ) result = sendDiceBotChatMessageOnece( paramsClone ) @logger.debug(result, "sendDiceBotChatMessageOnece result") next if( result.nil? ) results << result end @logger.debug(results, "sendDiceBotChatMessage results") return results end </syntaxhighlight> === L3659-L3669:<code>getDiceBotRepeatCount</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3659-L3669 コマンド送信回数を1〜20回に制限する。最近のRubyでは <code>(params['repeatCount'] || 1).clamp(1, 20)</code> と簡潔に書ける。 <syntaxhighlight lang="ruby"> def getDiceBotRepeatCount(params) repeatCountLimit = 20 repeatCount = params['repeatCount'] repeatCount ||= 1 repeatCount = 1 if( repeatCount < 1 ) repeatCount = repeatCountLimit if( repeatCount > repeatCountLimit ) return repeatCount end </syntaxhighlight> === L3672-L3709:<code>sendDiceBotChatMessageOnece</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3672-L3709 BCDiceに1回分(おそらく <code>Onece</code> は <code>once</code> のスペルミス)のコマンドを送る処理。<code>getRollDiceResult</code> でダイスロールした結果を取得する。<code>sendChatMessageByChatData</code>([https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3817-3839 L3817-3839])で、その結果を含むメッセージを送信する。 <syntaxhighlight lang="ruby"> def sendDiceBotChatMessageOnece(params) rolledMessage, isSecret, secretMessage = getRollDiceResult( params ) senderName = params['name'] unless /\t/ === senderName state = params['state'] senderName += ("\t" + state) unless( state.empty? ) end chatData = { "senderName" => senderName, "message" => rolledMessage, "color" => params['color'], "uniqueId" => '0', "channel" => params['channel'] } sendto = params['sendto'] unless( sendto.nil? ) chatData['sendto'] = sendto chatData['sendtoName'] = sendtoName end @logger.debug(chatData, 'sendDiceBotChatMessageOnece chatData') sendChatMessageByChatData(chatData) result = nil if( isSecret ) params['isSecret'] = isSecret params['message'] = secretMessage result = params end return result end </syntaxhighlight> === L3672-L3725:<code>getRollDiceResult</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3672-L3709 BCDiceでダイスを振る。シークレットダイスかどうかも考慮してメッセージを加工し、返す。 <syntaxhighlight lang="ruby"> def getRollDiceResult( params ) params['originalMessage'] = params['message'] rollResult, isSecret, randResults = @dice_adapter.rollDice(params) secretMessage = "" if( isSecret ) secretMessage = params['message'] + rollResult else params['message'] += rollResult end rolledMessage = getRolledMessage(params, isSecret, randResults) return rolledMessage, isSecret, secretMessage end </syntaxhighlight> === L3732-L3762:<code>getRolledMessage</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3732-L3709 ダイスロールの結果を入力として、どどんとふクライアントでの表示に必要な情報を付加する。シークレットダイスの場合に結果を隠すことと、「!」の数でサイコロを強調できるようにすることが目的のようだ。 <syntaxhighlight lang="ruby"> def getRolledMessage(params, isSecret, randResults) @logger.debug("getRolledMessage Begin") @logger.debug(isSecret, "isSecret") @logger.debug(randResults, "randResults") if( isSecret ) params['message'] = getLanguageKey('secretDice') randResults = randResults.collect{|value, max| [0, 0] } end message = params['message'] if( randResults.nil? ) @logger.debug("randResults is nil") return message end data = { "chatMessage" => message, "randResults" => randResults, "uniqueId" => params['uniqueId'], "power" => getDiceBotPower(params), } text = "###CutInCommand:rollVisualDice###" + getJsonString(data) @logger.debug(text, "getRolledMessage End text") return text end </syntaxhighlight> [[Category:BCDice/TRPGツールからの呼び出し方]] {{DEFAULTSORT:ととんとふ}} 6dca73bf5406fe96ed84b926607d18a1b228e8ef 106 105 2019-06-24T18:05:55Z Ochaochaocha3 1 /* src_ruby/dodontof/dice_adapter.rb:BCDiceとのアダプタ */ wikitext text/x-wiki [[どどんとふ]]からの[[BCDice]]の呼び出し方。このページでは、Rubyで書かれたどどんとふのサーバのダイス関連の処理を扱う。[https://github.com/torgtaitai/DodontoF/tree/d3e4cc374885986efc761cfabbb19e4b35e815e0 v1.49.04.01]のソースコードを参考にしている。 == 各ファイルの役割 == どどんとふのサーバでは、ダイスボットとの通信の処理は以下のファイルに記述されている。 * [https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb src_ruby/dodontof/dice_adapter.rb]:BCDiceとのアダプタ * [https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/diceBotInfos.rb src_ruby/diceBotInfos.rb]:ダイスボットの情報を取得する処理 * [https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb DodontoFServer.rb]:サーバ本体 == src_ruby/dodontof/dice_adapter.rb:BCDiceとのアダプタ == https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb ダイスロールと関係していることがすぐに分かるファイル名だが、実は大部分は独自の表からの情報の読み出しやファイル管理の処理となっている。 === L7-L10:<code>DiceAdapter#initialize</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L7-L10 アダプタを初期化する。 * <code>@dir</code>:部屋固有のデータ保存ディレクトリが設定される。詳細は「[[#L164-L185:@dice_adapter の初期化]]」で解説する。 * <code>@diceBotTablePrefix</code>:必ず <code>'diceBotTable_'</code> が設定される。 <syntaxhighlight lang="ruby"> def initialize(dir, prefix) @logger = DodontoF::Logger.instance @dir = dir @diceBotTablePrefix = prefix end </syntaxhighlight> === L13-L34:<code>DiceAdapter#rollDice</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L13-L34 ダイスロールを行う。メッセージ、ゲームシステム、出目を返すかが指定できる。結果のメッセージ、シークレットダイスかどうか、出目が返る。結果のメッセージの <code>'>'</code> は <code>'→'</code> に置換され、末尾の改行コードは削除される。 <syntaxhighlight lang="ruby"> def rollDice(params) require 'cgiDiceBot.rb' message = params['message'] gameType = params['gameType'] isNeedResult = params['isNeedResult'] @logger.debug(message, 'rollDice message') @logger.debug(gameType, 'rollDice gameType') bot = CgiDiceBot.new result, randResults = bot.roll(message, gameType, @dir, @diceBotTablePrefix, isNeedResult) result.gsub!(/>/, '→') result.sub!(/\r?\n?\Z/m, '') @logger.debug(result, 'rollDice result') @logger.debug(randResults, 'rollDice randResults') return result, bot.isSecret, randResults end </syntaxhighlight> === L36-L45:<code>DiceAdapter#getGameCommandInfos</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L36-L45 独自の表について、ゲームタイプ(ゲームの識別子)および含まれるコマンドの情報を返す。<code>CgiDiceBot#getGameCommandInfos</code> を経由して <code>TableFileData#getGameCommandInfos</code> を呼び出している。 <syntaxhighlight lang="ruby"> def getGameCommandInfos require 'cgiDiceBot.rb' bot = CgiDiceBot.new @logger.debug(@dir, 'dir') commandInfos = bot.getGameCommandInfos(@dir, @diceBotTablePrefix) @logger.debug(commandInfos, "getGameCommandInfos End commandInfos") return commandInfos end </syntaxhighlight> === L47-L63:<code>DiceAdapter#getBotTableInfosFromDir</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L47-L63 独自の表についての情報を取得する。<code>getGameCommandInfos</code> と似ているが、こちらの方が返される情報が詳しい? <syntaxhighlight lang="ruby"> def getBotTableInfosFromDir @logger.debug(@dir, 'getBotTableInfosFromDir dir') require 'TableFileData' isLoadCommonTable = false tableFileData = TableFileData.new( isLoadCommonTable ) tableFileData.setDir(@dir, @diceBotTablePrefix) tableInfos = tableFileData.getAllTableInfo @logger.debug(tableInfos, "getBotTableInfosFromDir tableInfos") tableInfos.sort!{|a, b| a["command"].to_i <=> b["command"].to_i} @logger.debug(tableInfos, 'getBotTableInfosFromDir result tableInfos') return tableInfos end </syntaxhighlight> === L65-L84:<code>DiceAdapter#addBotTableMain</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L65-L84 独自の表のファイルを保存する。 <syntaxhighlight lang="ruby"> def addBotTableMain(params) @logger.debug("addBotTableMain Begin") DodontoF::Utils.makeDir(@dir) require 'TableFileData' resultText = 'OK' begin creator = TableFileCreator.new(@dir, @diceBotTablePrefix, params) creator.execute rescue Exception => e @logger.exception(e) resultText = getLanguageKey( e.to_s ) end @logger.debug(resultText, "addBotTableMain End resultText") return resultText end </syntaxhighlight> === L86-L103:<code>DiceAdapter#changeBotTableMain</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L86-L103 独自の表のファイルを更新する。 <syntaxhighlight lang="ruby"> def changeBotTableMain(params) @logger.debug("changeBotTableMain Begin") require 'TableFileData' resultText = 'OK' begin creator = TableFileEditer.new(@dir, @diceBotTablePrefix, params) creator.execute rescue Exception => e @logger.exception(e) resultText = getLanguageKey( e.to_s ) end @logger.debug(resultText, "changeBotTableMain End resultText") return resultText end </syntaxhighlight> === L105-L135:<code>DiceAdapter#removeBotTableMain</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L86-L103 独自の表のファイルを削除する。 <syntaxhighlight lang="ruby"> def removeBotTableMain(params) @logger.debug("removeBotTableMain Begin") command = params["command"] require 'TableFileData' isLoadCommonTable = false tableFileData = TableFileData.new( isLoadCommonTable ) tableFileData.setDir(@dir, @diceBotTablePrefix) tableInfos = tableFileData.getAllTableInfo tableInfo = tableInfos.find{|i| i["command"] == command} @logger.debug(tableInfo, "tableInfo") return if( tableInfo.nil? ) fileName = tableInfo["fileName"] @logger.debug(fileName, "fileName") return if( fileName.nil? ) @logger.debug("isFile exist?") return unless( File.exist?(fileName) ) begin File.delete(fileName) rescue Exception => e @logger.exception(e) end @logger.debug("removeBotTableMain End") end </syntaxhighlight> == src_ruby/diceBotInfos.rb:ダイスボットの情報を取得する処理 == https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/diceBotInfos.rb === L69-L102:<code>DiceBotInfos.get</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/diceBotInfos.rb#L69-L102 <syntaxhighlight lang="ruby"> # ダイスボットの情報の一覧を取得する # @param [Array<String>] orderedGameNames 順序付けられたゲーム名の配列 # @param [Boolean] showAllDiceBots すべてのダイスボットを表示するか # @return [Array<Hash>] def self.get(orderedGameNames, showAllDiceBots) diceBots = DiceBotLoader.collectDiceBots # ゲーム名 => ダイスボットの対応を作る diceBotFor = Hash[ diceBots.map { |diceBot| [diceBot.gameName, diceBot] } ] toDiceBot = lambda { |gameName| diceBotFor[gameName] } orderedEnabledDiceBots = orderedGameNames. map(&toDiceBot). # ゲーム名が誤記されていた場合nilになるので除く compact orderedDiceBots = if showAllDiceBots disabledGameNames = diceBotFor.keys - orderedGameNames orderedDisabledDiceBots = disabledGameNames. sort. map(&toDiceBot) # 一覧に記載されていたゲーム→記載されていなかったゲームの順 orderedEnabledDiceBots + orderedDisabledDiceBots else orderedEnabledDiceBots end # 指定なし→各ゲーム→基本の順で返す [NONE_DICE_BOT_INFO] + orderedDiceBots.map(&:info) + [BASE_DICE_BOT_INFO] end </syntaxhighlight> === L104-150:<code>DiceBotInfos.withTableCommands</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/diceBotInfos.rb#L104-150 <syntaxhighlight lang="ruby"> # テーブルのコマンドも加えたダイスボットの情報の一覧を取得する # @param [Array<String>] orderedGameNames 順序付けられたゲーム名の配列 # @param [Boolean] showAllDiceBots すべてのダイスボットを表示するか # @param [Array<Hash>] commandInfos テーブルのコマンドの情報の配列 # @return [Array<Hash>] # # このメソッドは、ダイスボットから返された情報を破壊しない。 def self.withTableCommands(orderedGameNames, showAllDiceBots, commandInfos) diceBotInfos = self.get(orderedGameNames, showAllDiceBots) # ゲームタイプ => ダイスボット情報のインデックスの対応を作る diceBotInfoIndexFor = Hash[ diceBotInfos.each_with_index.map { |info, i| [info[KEY_GAME_TYPE], i] } ] allGameTypes = diceBotInfoIndexFor.keys # ゲームタイプ => 追加するコマンドの一覧の対応を作る commandsToAdd = commandInfos.reduce({}) { |acc, commandInfo| gameType = commandInfo[KEY_GAME_TYPE] command = commandInfo[KEY_COMMAND] # ゲームタイプ未指定ならすべてのゲームタイプに追加する targetGameTypes = gameType.empty? ? allGameTypes : [gameType] targetGameTypes.each do |targetGameType| acc[targetGameType] ||= [] acc[targetGameType] << command end acc } commandsToAdd.each do |gameType, commands| diceBotInfoIndex = diceBotInfoIndexFor[gameType] next unless diceBotInfoIndex originalInfo = diceBotInfos[diceBotInfoIndex] # ダイスボットから返された情報を破壊しないようにして更新する diceBotInfos[diceBotInfoIndex] = originalInfo.merge({ KEY_PREFIXS => originalInfo[KEY_PREFIXS] + commands }) end diceBotInfos end </syntaxhighlight> == DodontoFServer.rb:サーバ本体 == https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb === L164-L185:<code>@dice_adapter</code> の初期化 === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L164-L185 <syntaxhighlight lang="ruby"> def initialize(saveDirInfo, cgiParams) @cgiParams = cgiParams @saveDirInfo = saveDirInfo @logger = DodontoF::Logger.instance @cgi = nil @jsonpCallBack = nil @isWebIf = false @isRecordEmpty = false initSaveFiles(getRequestData('room')) @dice_adapter = DodontoF::DiceAdapter.new(getDiceBotExtraTableDirName, 'diceBotTable_') @fullBackupFileBaseName = "DodontoFFullBackup" @allSaveDataFileExt = '.tar.gz' @defaultAllSaveData = 'default.sav' @defaultChatPallete = 'default.cpd' @card = nil end </syntaxhighlight> <code>getDiceBotExtraTableDirName</code>([https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3727-L3729 L3727-L3729])では、<code>getRoomLocalSpaceDirName</code>([https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3262-L3265 L3262-L3265])、<code>getRoomLocalSpaceDirNameByRoomNo</code>([https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3267-L3273 L3267-L3273])を経由して、<code>$imageUploadDir</code> の中の部屋固有のディレクトリを返す。 === L1193-L1210:<code>getWebIfServerInfo</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L1193-L1210 Webインターフェースのサーバ情報を返すコマンド。<code>getDiceBotInfos</code> でダイスボットの情報を取得する。 <syntaxhighlight lang="ruby"> def getWebIfServerInfo() jsonData = { "maxRoom" => ($saveDataMaxCount - 1), 'isNeedCreatePassword' => (not $createPlayRoomPassword.empty?), 'result' => 'OK', } if( getWebIfRequestBoolean("card", false) ) cardInfos = getCardsInfo.collectCardTypeAndTypeName($cardOrder) jsonData["cardInfos"] = cardInfos end if( getWebIfRequestBoolean("dice", false) ) jsonData['diceBotInfos'] = getDiceBotInfos() end return jsonData end </syntaxhighlight> === L2090:<code>getLoginInfo</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2090 ダイスボット情報の取得を行う。 <syntaxhighlight lang="ruby"> diceBotInfos = getDiceBotInfos() </syntaxhighlight> === L2266-L2280:<code>getDiceBotInfos</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2266-L2280 ダイスボット情報取得処理の実装。部屋に入っているかどうかで、テーブルのコマンドも含めた情報を返すかどうかを決定している。 <syntaxhighlight lang="ruby"> def getDiceBotInfos @logger.debug("getDiceBotInfos() Begin") require 'diceBotInfos' orderedGameNames = $diceBotOrder.split("\n") if @saveDirInfo.getSaveDataDirIndex != -1 DiceBotInfos.withTableCommands(orderedGameNames, $isDisplayAllDice, @dice_adapter.getGameCommandInfos) else DiceBotInfos.get(orderedGameNames, $isDisplayAllDice) end end </syntaxhighlight> === L2542-2556:<code>save</code>, <code>getDiceTableData</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2542-2556 部屋のデータの保存時に、独自の表についての情報を取得する。 <syntaxhighlight lang="ruby"> def save() isAddPlayRoomInfo = true extension = @@saveFileExtension addInfos = {} addInfos[$diceBotTableSaveKey] = getDiceTableData() saveSelectFiles($saveFiles.keys, extension, isAddPlayRoomInfo, addInfos) end def getDiceTableData() tableInfos = @dice_adapter.getBotTableInfosFromDir tableInfos.each{|i| i.delete('fileName') } return tableInfos end </syntaxhighlight> === L2806-L2817:<code>getBotTableInfos</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2806-L2817 独自の表についての情報を取得する。 <syntaxhighlight lang="ruby"> def getBotTableInfos() @logger.debug("getBotTableInfos Begin") result = { "resultText"=> "OK", } result["tableInfos"] = @dice_adapter.getBotTableInfosFromDir @logger.debug(result, "result") @logger.debug("getBotTableInfos End") return result end </syntaxhighlight> === L2819-L2835:<code>addBotTable</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2819-L2835 独自の表を追加する。 <syntaxhighlight lang="ruby"> def addBotTable() result = {} params = getParamsFromRequestData() result['resultText'] = @dice_adapter.addBotTableMain(params) if( result['resultText'] != "OK" ) return result end @logger.debug("addBotTableMain called") result = getBotTableInfos() @logger.debug(result, "addBotTable result") return result end </syntaxhighlight> === L2837-L2849:<code>changeBotTable</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2837-L2849 独自の表を変更する。 <syntaxhighlight lang="ruby"> def changeBotTable() params = getParamsFromRequestData() result = {} result['resultText'] = @dice_adapter.changeBotTableMain(params) if( result['resultText'] != "OK" ) return result end result = getBotTableInfos() return result end </syntaxhighlight> === L2851-L2855:<code>removeBotTable</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2851-L2855 独自の表を削除する。 <syntaxhighlight lang="ruby"> def removeBotTable() params = getParamsFromRequestData() @dice_adapter.removeBotTableMain(params) return getBotTableInfos() end </syntaxhighlight> === L3458-L3459:<code>loadSaveFileDataFilterByTargets</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3458-L3459 セーブデータの部分読み込み処理の一部。独自の表を読み込む。 <syntaxhighlight lang="ruby"> when "diceBotTable" loadDiceBotTable(jsonData) </syntaxhighlight> === L3511-L3531:<code>loadDiceBotTable</code>, <code>getDiceBotTableString</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3511-L3531 独自の表を読み込む。 <syntaxhighlight lang="ruby"> def loadDiceBotTable(jsonData) data = jsonData[$diceBotTableSaveKey] return if( data.nil? ) data.each do |info| info['table'] = getDiceBotTableString(info['table']) @dice_adapter.addBotTableMain(info) end end def getDiceBotTableString(table) lines = [] table.each do |line| lines << line.join(":") end return lines.join("\n") end </syntaxhighlight> === L3632-L3657:<code>sendDiceBotChatMessage</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3632-L3657 BCDiceにコマンドを送る処理。<code>回数 コマンド</code> という形で送信回数が指定されていた場合は、指定された回数だけコマンドをBCDiceに送る。 <syntaxhighlight lang="ruby"> def sendDiceBotChatMessage @logger.debug('sendDiceBotChatMessage') params = getParamsFromRequestData() repeatCount = getDiceBotRepeatCount(params) results = [] repeatCount.times do |i| paramsClone = params.clone paramsClone['message'] += " \##{ i + 1 }" if( repeatCount > 1 ) result = sendDiceBotChatMessageOnece( paramsClone ) @logger.debug(result, "sendDiceBotChatMessageOnece result") next if( result.nil? ) results << result end @logger.debug(results, "sendDiceBotChatMessage results") return results end </syntaxhighlight> === L3659-L3669:<code>getDiceBotRepeatCount</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3659-L3669 コマンド送信回数を1〜20回に制限する。最近のRubyでは <code>(params['repeatCount'] || 1).clamp(1, 20)</code> と簡潔に書ける。 <syntaxhighlight lang="ruby"> def getDiceBotRepeatCount(params) repeatCountLimit = 20 repeatCount = params['repeatCount'] repeatCount ||= 1 repeatCount = 1 if( repeatCount < 1 ) repeatCount = repeatCountLimit if( repeatCount > repeatCountLimit ) return repeatCount end </syntaxhighlight> === L3672-L3709:<code>sendDiceBotChatMessageOnece</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3672-L3709 BCDiceに1回分(おそらく <code>Onece</code> は <code>once</code> のスペルミス)のコマンドを送る処理。<code>getRollDiceResult</code> でダイスロールした結果を取得する。<code>sendChatMessageByChatData</code>([https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3817-3839 L3817-3839])で、その結果を含むメッセージを送信する。 <syntaxhighlight lang="ruby"> def sendDiceBotChatMessageOnece(params) rolledMessage, isSecret, secretMessage = getRollDiceResult( params ) senderName = params['name'] unless /\t/ === senderName state = params['state'] senderName += ("\t" + state) unless( state.empty? ) end chatData = { "senderName" => senderName, "message" => rolledMessage, "color" => params['color'], "uniqueId" => '0', "channel" => params['channel'] } sendto = params['sendto'] unless( sendto.nil? ) chatData['sendto'] = sendto chatData['sendtoName'] = sendtoName end @logger.debug(chatData, 'sendDiceBotChatMessageOnece chatData') sendChatMessageByChatData(chatData) result = nil if( isSecret ) params['isSecret'] = isSecret params['message'] = secretMessage result = params end return result end </syntaxhighlight> === L3672-L3725:<code>getRollDiceResult</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3672-L3709 BCDiceでダイスを振る。シークレットダイスかどうかも考慮してメッセージを加工し、返す。 <syntaxhighlight lang="ruby"> def getRollDiceResult( params ) params['originalMessage'] = params['message'] rollResult, isSecret, randResults = @dice_adapter.rollDice(params) secretMessage = "" if( isSecret ) secretMessage = params['message'] + rollResult else params['message'] += rollResult end rolledMessage = getRolledMessage(params, isSecret, randResults) return rolledMessage, isSecret, secretMessage end </syntaxhighlight> === L3732-L3762:<code>getRolledMessage</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3732-L3709 ダイスロールの結果を入力として、どどんとふクライアントでの表示に必要な情報を付加する。シークレットダイスの場合に結果を隠すことと、「!」の数でサイコロを強調できるようにすることが目的のようだ。 <syntaxhighlight lang="ruby"> def getRolledMessage(params, isSecret, randResults) @logger.debug("getRolledMessage Begin") @logger.debug(isSecret, "isSecret") @logger.debug(randResults, "randResults") if( isSecret ) params['message'] = getLanguageKey('secretDice') randResults = randResults.collect{|value, max| [0, 0] } end message = params['message'] if( randResults.nil? ) @logger.debug("randResults is nil") return message end data = { "chatMessage" => message, "randResults" => randResults, "uniqueId" => params['uniqueId'], "power" => getDiceBotPower(params), } text = "###CutInCommand:rollVisualDice###" + getJsonString(data) @logger.debug(text, "getRolledMessage End text") return text end </syntaxhighlight> [[Category:BCDice/TRPGツールからの呼び出し方]] {{DEFAULTSORT:ととんとふ}} 50fb2f075ece4f5635ff5dec416c71fa283cd173 107 106 2019-06-24T18:11:48Z Ochaochaocha3 1 サーバー本体:見出しにクラス名を追加する wikitext text/x-wiki [[どどんとふ]]からの[[BCDice]]の呼び出し方。このページでは、Rubyで書かれたどどんとふのサーバのダイス関連の処理を扱う。[https://github.com/torgtaitai/DodontoF/tree/d3e4cc374885986efc761cfabbb19e4b35e815e0 v1.49.04.01]のソースコードを参考にしている。 == 各ファイルの役割 == どどんとふのサーバでは、ダイスボットとの通信の処理は以下のファイルに記述されている。 * [https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb src_ruby/dodontof/dice_adapter.rb]:BCDiceとのアダプタ * [https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/diceBotInfos.rb src_ruby/diceBotInfos.rb]:ダイスボットの情報を取得する処理 * [https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb DodontoFServer.rb]:サーバ本体 == src_ruby/dodontof/dice_adapter.rb:BCDiceとのアダプタ == https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb ダイスロールと関係していることがすぐに分かるファイル名だが、実は大部分は独自の表からの情報の読み出しやファイル管理の処理となっている。 === L7-L10:<code>DiceAdapter#initialize</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L7-L10 アダプタを初期化する。 * <code>@dir</code>:部屋固有のデータ保存ディレクトリが設定される。詳細は「[[#L164-L185:@dice_adapter の初期化]]」で解説する。 * <code>@diceBotTablePrefix</code>:必ず <code>'diceBotTable_'</code> が設定される。 <syntaxhighlight lang="ruby"> def initialize(dir, prefix) @logger = DodontoF::Logger.instance @dir = dir @diceBotTablePrefix = prefix end </syntaxhighlight> === L13-L34:<code>DiceAdapter#rollDice</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L13-L34 ダイスロールを行う。メッセージ、ゲームシステム、出目を返すかが指定できる。結果のメッセージ、シークレットダイスかどうか、出目が返る。結果のメッセージの <code>'>'</code> は <code>'→'</code> に置換され、末尾の改行コードは削除される。 <syntaxhighlight lang="ruby"> def rollDice(params) require 'cgiDiceBot.rb' message = params['message'] gameType = params['gameType'] isNeedResult = params['isNeedResult'] @logger.debug(message, 'rollDice message') @logger.debug(gameType, 'rollDice gameType') bot = CgiDiceBot.new result, randResults = bot.roll(message, gameType, @dir, @diceBotTablePrefix, isNeedResult) result.gsub!(/>/, '→') result.sub!(/\r?\n?\Z/m, '') @logger.debug(result, 'rollDice result') @logger.debug(randResults, 'rollDice randResults') return result, bot.isSecret, randResults end </syntaxhighlight> === L36-L45:<code>DiceAdapter#getGameCommandInfos</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L36-L45 独自の表について、ゲームタイプ(ゲームの識別子)および含まれるコマンドの情報を返す。<code>CgiDiceBot#getGameCommandInfos</code> を経由して <code>TableFileData#getGameCommandInfos</code> を呼び出している。 <syntaxhighlight lang="ruby"> def getGameCommandInfos require 'cgiDiceBot.rb' bot = CgiDiceBot.new @logger.debug(@dir, 'dir') commandInfos = bot.getGameCommandInfos(@dir, @diceBotTablePrefix) @logger.debug(commandInfos, "getGameCommandInfos End commandInfos") return commandInfos end </syntaxhighlight> === L47-L63:<code>DiceAdapter#getBotTableInfosFromDir</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L47-L63 独自の表についての情報を取得する。<code>getGameCommandInfos</code> と似ているが、こちらの方が返される情報が詳しい? <syntaxhighlight lang="ruby"> def getBotTableInfosFromDir @logger.debug(@dir, 'getBotTableInfosFromDir dir') require 'TableFileData' isLoadCommonTable = false tableFileData = TableFileData.new( isLoadCommonTable ) tableFileData.setDir(@dir, @diceBotTablePrefix) tableInfos = tableFileData.getAllTableInfo @logger.debug(tableInfos, "getBotTableInfosFromDir tableInfos") tableInfos.sort!{|a, b| a["command"].to_i <=> b["command"].to_i} @logger.debug(tableInfos, 'getBotTableInfosFromDir result tableInfos') return tableInfos end </syntaxhighlight> === L65-L84:<code>DiceAdapter#addBotTableMain</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L65-L84 独自の表のファイルを保存する。 <syntaxhighlight lang="ruby"> def addBotTableMain(params) @logger.debug("addBotTableMain Begin") DodontoF::Utils.makeDir(@dir) require 'TableFileData' resultText = 'OK' begin creator = TableFileCreator.new(@dir, @diceBotTablePrefix, params) creator.execute rescue Exception => e @logger.exception(e) resultText = getLanguageKey( e.to_s ) end @logger.debug(resultText, "addBotTableMain End resultText") return resultText end </syntaxhighlight> === L86-L103:<code>DiceAdapter#changeBotTableMain</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L86-L103 独自の表のファイルを更新する。 <syntaxhighlight lang="ruby"> def changeBotTableMain(params) @logger.debug("changeBotTableMain Begin") require 'TableFileData' resultText = 'OK' begin creator = TableFileEditer.new(@dir, @diceBotTablePrefix, params) creator.execute rescue Exception => e @logger.exception(e) resultText = getLanguageKey( e.to_s ) end @logger.debug(resultText, "changeBotTableMain End resultText") return resultText end </syntaxhighlight> === L105-L135:<code>DiceAdapter#removeBotTableMain</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L86-L103 独自の表のファイルを削除する。 <syntaxhighlight lang="ruby"> def removeBotTableMain(params) @logger.debug("removeBotTableMain Begin") command = params["command"] require 'TableFileData' isLoadCommonTable = false tableFileData = TableFileData.new( isLoadCommonTable ) tableFileData.setDir(@dir, @diceBotTablePrefix) tableInfos = tableFileData.getAllTableInfo tableInfo = tableInfos.find{|i| i["command"] == command} @logger.debug(tableInfo, "tableInfo") return if( tableInfo.nil? ) fileName = tableInfo["fileName"] @logger.debug(fileName, "fileName") return if( fileName.nil? ) @logger.debug("isFile exist?") return unless( File.exist?(fileName) ) begin File.delete(fileName) rescue Exception => e @logger.exception(e) end @logger.debug("removeBotTableMain End") end </syntaxhighlight> == src_ruby/diceBotInfos.rb:ダイスボットの情報を取得する処理 == https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/diceBotInfos.rb === L69-L102:<code>DiceBotInfos.get</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/diceBotInfos.rb#L69-L102 <syntaxhighlight lang="ruby"> # ダイスボットの情報の一覧を取得する # @param [Array<String>] orderedGameNames 順序付けられたゲーム名の配列 # @param [Boolean] showAllDiceBots すべてのダイスボットを表示するか # @return [Array<Hash>] def self.get(orderedGameNames, showAllDiceBots) diceBots = DiceBotLoader.collectDiceBots # ゲーム名 => ダイスボットの対応を作る diceBotFor = Hash[ diceBots.map { |diceBot| [diceBot.gameName, diceBot] } ] toDiceBot = lambda { |gameName| diceBotFor[gameName] } orderedEnabledDiceBots = orderedGameNames. map(&toDiceBot). # ゲーム名が誤記されていた場合nilになるので除く compact orderedDiceBots = if showAllDiceBots disabledGameNames = diceBotFor.keys - orderedGameNames orderedDisabledDiceBots = disabledGameNames. sort. map(&toDiceBot) # 一覧に記載されていたゲーム→記載されていなかったゲームの順 orderedEnabledDiceBots + orderedDisabledDiceBots else orderedEnabledDiceBots end # 指定なし→各ゲーム→基本の順で返す [NONE_DICE_BOT_INFO] + orderedDiceBots.map(&:info) + [BASE_DICE_BOT_INFO] end </syntaxhighlight> === L104-150:<code>DiceBotInfos.withTableCommands</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/diceBotInfos.rb#L104-150 <syntaxhighlight lang="ruby"> # テーブルのコマンドも加えたダイスボットの情報の一覧を取得する # @param [Array<String>] orderedGameNames 順序付けられたゲーム名の配列 # @param [Boolean] showAllDiceBots すべてのダイスボットを表示するか # @param [Array<Hash>] commandInfos テーブルのコマンドの情報の配列 # @return [Array<Hash>] # # このメソッドは、ダイスボットから返された情報を破壊しない。 def self.withTableCommands(orderedGameNames, showAllDiceBots, commandInfos) diceBotInfos = self.get(orderedGameNames, showAllDiceBots) # ゲームタイプ => ダイスボット情報のインデックスの対応を作る diceBotInfoIndexFor = Hash[ diceBotInfos.each_with_index.map { |info, i| [info[KEY_GAME_TYPE], i] } ] allGameTypes = diceBotInfoIndexFor.keys # ゲームタイプ => 追加するコマンドの一覧の対応を作る commandsToAdd = commandInfos.reduce({}) { |acc, commandInfo| gameType = commandInfo[KEY_GAME_TYPE] command = commandInfo[KEY_COMMAND] # ゲームタイプ未指定ならすべてのゲームタイプに追加する targetGameTypes = gameType.empty? ? allGameTypes : [gameType] targetGameTypes.each do |targetGameType| acc[targetGameType] ||= [] acc[targetGameType] << command end acc } commandsToAdd.each do |gameType, commands| diceBotInfoIndex = diceBotInfoIndexFor[gameType] next unless diceBotInfoIndex originalInfo = diceBotInfos[diceBotInfoIndex] # ダイスボットから返された情報を破壊しないようにして更新する diceBotInfos[diceBotInfoIndex] = originalInfo.merge({ KEY_PREFIXS => originalInfo[KEY_PREFIXS] + commands }) end diceBotInfos end </syntaxhighlight> == DodontoFServer.rb:サーバ本体 == https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb === L164-L185:<code>@dice_adapter</code> の初期化 === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L164-L185 <syntaxhighlight lang="ruby"> def initialize(saveDirInfo, cgiParams) @cgiParams = cgiParams @saveDirInfo = saveDirInfo @logger = DodontoF::Logger.instance @cgi = nil @jsonpCallBack = nil @isWebIf = false @isRecordEmpty = false initSaveFiles(getRequestData('room')) @dice_adapter = DodontoF::DiceAdapter.new(getDiceBotExtraTableDirName, 'diceBotTable_') @fullBackupFileBaseName = "DodontoFFullBackup" @allSaveDataFileExt = '.tar.gz' @defaultAllSaveData = 'default.sav' @defaultChatPallete = 'default.cpd' @card = nil end </syntaxhighlight> <code>getDiceBotExtraTableDirName</code>([https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3727-L3729 L3727-L3729])では、<code>getRoomLocalSpaceDirName</code>([https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3262-L3265 L3262-L3265])、<code>getRoomLocalSpaceDirNameByRoomNo</code>([https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3267-L3273 L3267-L3273])を経由して、<code>$imageUploadDir</code> の中の部屋固有のディレクトリを返す。 === L1193-L1210:<code>DodontoFServer#getWebIfServerInfo</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L1193-L1210 Webインターフェースのサーバ情報を返すコマンド。<code>getDiceBotInfos</code> でダイスボットの情報を取得する。 <syntaxhighlight lang="ruby"> def getWebIfServerInfo() jsonData = { "maxRoom" => ($saveDataMaxCount - 1), 'isNeedCreatePassword' => (not $createPlayRoomPassword.empty?), 'result' => 'OK', } if( getWebIfRequestBoolean("card", false) ) cardInfos = getCardsInfo.collectCardTypeAndTypeName($cardOrder) jsonData["cardInfos"] = cardInfos end if( getWebIfRequestBoolean("dice", false) ) jsonData['diceBotInfos'] = getDiceBotInfos() end return jsonData end </syntaxhighlight> === L2090:<code>DodontoFServer#getLoginInfo</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2090 ダイスボット情報の取得を行う。 <syntaxhighlight lang="ruby"> diceBotInfos = getDiceBotInfos() </syntaxhighlight> === L2266-L2280:<code>DodontoFServer#getDiceBotInfos</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2266-L2280 ダイスボット情報取得処理の実装。部屋に入っているかどうかで、テーブルのコマンドも含めた情報を返すかどうかを決定している。 <syntaxhighlight lang="ruby"> def getDiceBotInfos @logger.debug("getDiceBotInfos() Begin") require 'diceBotInfos' orderedGameNames = $diceBotOrder.split("\n") if @saveDirInfo.getSaveDataDirIndex != -1 DiceBotInfos.withTableCommands(orderedGameNames, $isDisplayAllDice, @dice_adapter.getGameCommandInfos) else DiceBotInfos.get(orderedGameNames, $isDisplayAllDice) end end </syntaxhighlight> === L2542-2556:<code>DodontoFServer#save</code>, <code>getDiceTableData</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2542-2556 部屋のデータの保存時に、独自の表についての情報を取得する。 <syntaxhighlight lang="ruby"> def save() isAddPlayRoomInfo = true extension = @@saveFileExtension addInfos = {} addInfos[$diceBotTableSaveKey] = getDiceTableData() saveSelectFiles($saveFiles.keys, extension, isAddPlayRoomInfo, addInfos) end def getDiceTableData() tableInfos = @dice_adapter.getBotTableInfosFromDir tableInfos.each{|i| i.delete('fileName') } return tableInfos end </syntaxhighlight> === L2806-L2817:<code>DodontoFServer#getBotTableInfos</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2806-L2817 独自の表についての情報を取得する。 <syntaxhighlight lang="ruby"> def getBotTableInfos() @logger.debug("getBotTableInfos Begin") result = { "resultText"=> "OK", } result["tableInfos"] = @dice_adapter.getBotTableInfosFromDir @logger.debug(result, "result") @logger.debug("getBotTableInfos End") return result end </syntaxhighlight> === L2819-L2835:<code>DodontoFServer#addBotTable</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2819-L2835 独自の表を追加する。 <syntaxhighlight lang="ruby"> def addBotTable() result = {} params = getParamsFromRequestData() result['resultText'] = @dice_adapter.addBotTableMain(params) if( result['resultText'] != "OK" ) return result end @logger.debug("addBotTableMain called") result = getBotTableInfos() @logger.debug(result, "addBotTable result") return result end </syntaxhighlight> === L2837-L2849:<code>DodontoFServer#changeBotTable</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2837-L2849 独自の表を変更する。 <syntaxhighlight lang="ruby"> def changeBotTable() params = getParamsFromRequestData() result = {} result['resultText'] = @dice_adapter.changeBotTableMain(params) if( result['resultText'] != "OK" ) return result end result = getBotTableInfos() return result end </syntaxhighlight> === L2851-L2855:<code>DodontoFServer#removeBotTable</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2851-L2855 独自の表を削除する。 <syntaxhighlight lang="ruby"> def removeBotTable() params = getParamsFromRequestData() @dice_adapter.removeBotTableMain(params) return getBotTableInfos() end </syntaxhighlight> === L3458-L3459:<code>DodontoFServer#loadSaveFileDataFilterByTargets</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3458-L3459 セーブデータの部分読み込み処理の一部。独自の表を読み込む。 <syntaxhighlight lang="ruby"> when "diceBotTable" loadDiceBotTable(jsonData) </syntaxhighlight> === L3511-L3531:<code>DodontoFServer#loadDiceBotTable</code>, <code>DodontoFServer#getDiceBotTableString</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3511-L3531 独自の表を読み込む。 <syntaxhighlight lang="ruby"> def loadDiceBotTable(jsonData) data = jsonData[$diceBotTableSaveKey] return if( data.nil? ) data.each do |info| info['table'] = getDiceBotTableString(info['table']) @dice_adapter.addBotTableMain(info) end end def getDiceBotTableString(table) lines = [] table.each do |line| lines << line.join(":") end return lines.join("\n") end </syntaxhighlight> === L3632-L3657:<code>DodontoFServer#sendDiceBotChatMessage</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3632-L3657 BCDiceにコマンドを送る処理。<code>回数 コマンド</code> という形で送信回数が指定されていた場合は、指定された回数だけコマンドをBCDiceに送る。 <syntaxhighlight lang="ruby"> def sendDiceBotChatMessage @logger.debug('sendDiceBotChatMessage') params = getParamsFromRequestData() repeatCount = getDiceBotRepeatCount(params) results = [] repeatCount.times do |i| paramsClone = params.clone paramsClone['message'] += " \##{ i + 1 }" if( repeatCount > 1 ) result = sendDiceBotChatMessageOnece( paramsClone ) @logger.debug(result, "sendDiceBotChatMessageOnece result") next if( result.nil? ) results << result end @logger.debug(results, "sendDiceBotChatMessage results") return results end </syntaxhighlight> === L3659-L3669:<code>DodontoFServer#getDiceBotRepeatCount</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3659-L3669 コマンド送信回数を1〜20回に制限する。最近のRubyでは <code>(params['repeatCount'] || 1).clamp(1, 20)</code> と簡潔に書ける。 <syntaxhighlight lang="ruby"> def getDiceBotRepeatCount(params) repeatCountLimit = 20 repeatCount = params['repeatCount'] repeatCount ||= 1 repeatCount = 1 if( repeatCount < 1 ) repeatCount = repeatCountLimit if( repeatCount > repeatCountLimit ) return repeatCount end </syntaxhighlight> === L3672-L3709:<code>DodontoFServer#sendDiceBotChatMessageOnece</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3672-L3709 BCDiceに1回分(おそらく <code>Onece</code> は <code>once</code> のスペルミス)のコマンドを送る処理。<code>getRollDiceResult</code> でダイスロールした結果を取得する。<code>sendChatMessageByChatData</code>([https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3817-3839 L3817-3839])で、その結果を含むメッセージを送信する。 <syntaxhighlight lang="ruby"> def sendDiceBotChatMessageOnece(params) rolledMessage, isSecret, secretMessage = getRollDiceResult( params ) senderName = params['name'] unless /\t/ === senderName state = params['state'] senderName += ("\t" + state) unless( state.empty? ) end chatData = { "senderName" => senderName, "message" => rolledMessage, "color" => params['color'], "uniqueId" => '0', "channel" => params['channel'] } sendto = params['sendto'] unless( sendto.nil? ) chatData['sendto'] = sendto chatData['sendtoName'] = sendtoName end @logger.debug(chatData, 'sendDiceBotChatMessageOnece chatData') sendChatMessageByChatData(chatData) result = nil if( isSecret ) params['isSecret'] = isSecret params['message'] = secretMessage result = params end return result end </syntaxhighlight> === L3672-L3725:<code>DodontoFServer#getRollDiceResult</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3672-L3709 BCDiceでダイスを振る。シークレットダイスかどうかも考慮してメッセージを加工し、返す。 <syntaxhighlight lang="ruby"> def getRollDiceResult( params ) params['originalMessage'] = params['message'] rollResult, isSecret, randResults = @dice_adapter.rollDice(params) secretMessage = "" if( isSecret ) secretMessage = params['message'] + rollResult else params['message'] += rollResult end rolledMessage = getRolledMessage(params, isSecret, randResults) return rolledMessage, isSecret, secretMessage end </syntaxhighlight> === L3732-L3762:<code>DodontoFServer#getRolledMessage</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3732-L3709 ダイスロールの結果を入力として、どどんとふクライアントでの表示に必要な情報を付加する。シークレットダイスの場合に結果を隠すことと、「!」の数でサイコロを強調できるようにすることが目的のようだ。 <syntaxhighlight lang="ruby"> def getRolledMessage(params, isSecret, randResults) @logger.debug("getRolledMessage Begin") @logger.debug(isSecret, "isSecret") @logger.debug(randResults, "randResults") if( isSecret ) params['message'] = getLanguageKey('secretDice') randResults = randResults.collect{|value, max| [0, 0] } end message = params['message'] if( randResults.nil? ) @logger.debug("randResults is nil") return message end data = { "chatMessage" => message, "randResults" => randResults, "uniqueId" => params['uniqueId'], "power" => getDiceBotPower(params), } text = "###CutInCommand:rollVisualDice###" + getJsonString(data) @logger.debug(text, "getRolledMessage End text") return text end </syntaxhighlight> [[Category:BCDice/TRPGツールからの呼び出し方]] {{DEFAULTSORT:ととんとふ}} 5de9b82e89eea7a328b3c62e7996f55f3906f668 BCDice/TRPGツールからの呼び出し方 0 15 108 36 2019-06-27T00:43:05Z Ochaochaocha3 1 /* Rubyで書かれたBCDiceを使用するツール */ TRPGツールを2つの種類に分ける wikitext text/x-wiki 本ページ以下では、様々なオンラインセッションツールから現在の[[BCDice]]をどのように呼び出しているかをまとめる。 == Rubyで書かれたBCDiceを使用するツール == === BCDiceの全機能を利用するツール === * [[/どどんとふ]] === ダイスボットのみを利用するツール === * [[/BCDice-API]] * [[/Onset!]] * [[/オンセンルーム]] == BCDice-APIを使用するツール == * [[Quoridorn]] ** v1.0.0b12:[https://github.com/HillTopTRPG/quoridorn-vue-cli-3/blob/bc39e134a367325a09c0e5257e5c50f9a91237a7/src/store/state_setting.ts#L51-L119 src/store/state_setting.ts#L51-L119] に呼び出す処理がある。 * [[Saipage]] ** コミット 723cbdb:[https://github.com/ysakasin/saipage/blob/723cbdbc20ad830e31dd6096bfcb39b14266bf49/client/dice.ts client/dice.ts] に呼び出す処理がある。 == JavaScriptに変換したBCDiceを使用するツール == BCDiceをOpalでJavaScriptに変換して使用する。 * [[ねこ卓]]:[https://github.com/ukatama/bcdice-js bcdice-js]を使用する。 * [[ユドナリウム]] [[Category:BCDice]] {{DEFAULTSORT:TRPGつうるからのよひたしかた}} 2d2d823c3c0315044eeeceacf9ee681fbe29fc3d 109 108 2019-06-27T00:50:45Z Ochaochaocha3 1 /* Rubyで書かれたBCDiceを使用するツール */ wikitext text/x-wiki 本ページ以下では、様々なオンラインセッションツールから現在の[[BCDice]]をどのように呼び出しているかをまとめる。 == Rubyで書かれたBCDiceを使用するツール == === BCDiceの全機能を利用するツール === * [[/どどんとふ]] === ダイスロールのみを利用するツール === * [[/BCDice-API]] * [[/Onset!]] * [[/オンセンルーム]] == BCDice-APIを使用するツール == * [[Quoridorn]] ** v1.0.0b12:[https://github.com/HillTopTRPG/quoridorn-vue-cli-3/blob/bc39e134a367325a09c0e5257e5c50f9a91237a7/src/store/state_setting.ts#L51-L119 src/store/state_setting.ts#L51-L119] に呼び出す処理がある。 * [[Saipage]] ** コミット 723cbdb:[https://github.com/ysakasin/saipage/blob/723cbdbc20ad830e31dd6096bfcb39b14266bf49/client/dice.ts client/dice.ts] に呼び出す処理がある。 == JavaScriptに変換したBCDiceを使用するツール == BCDiceをOpalでJavaScriptに変換して使用する。 * [[ねこ卓]]:[https://github.com/ukatama/bcdice-js bcdice-js]を使用する。 * [[ユドナリウム]] [[Category:BCDice]] {{DEFAULTSORT:TRPGつうるからのよひたしかた}} 8ad8ab48da635bf84d2cf2d8f9fcd1f7f336c2d5 115 109 2019-06-27T04:18:37Z Ochaochaocha3 1 /* ダイスロールのみを利用するツール */ wikitext text/x-wiki 本ページ以下では、様々なオンラインセッションツールから現在の[[BCDice]]をどのように呼び出しているかをまとめる。 == Rubyで書かれたBCDiceを使用するツール == === BCDiceの全機能を利用するツール === * [[/どどんとふ]] === ダイスロールのみを利用するツール === 呼び出し方の概要:[[/ダイスロールのみ利用する場合]] * [[/BCDice-API]] * [[/Onset!]] * [[/オンセンルーム]] == BCDice-APIを使用するツール == * [[Quoridorn]] ** v1.0.0b12:[https://github.com/HillTopTRPG/quoridorn-vue-cli-3/blob/bc39e134a367325a09c0e5257e5c50f9a91237a7/src/store/state_setting.ts#L51-L119 src/store/state_setting.ts#L51-L119] に呼び出す処理がある。 * [[Saipage]] ** コミット 723cbdb:[https://github.com/ysakasin/saipage/blob/723cbdbc20ad830e31dd6096bfcb39b14266bf49/client/dice.ts client/dice.ts] に呼び出す処理がある。 == JavaScriptに変換したBCDiceを使用するツール == BCDiceをOpalでJavaScriptに変換して使用する。 * [[ねこ卓]]:[https://github.com/ukatama/bcdice-js bcdice-js]を使用する。 * [[ユドナリウム]] [[Category:BCDice]] {{DEFAULTSORT:TRPGつうるからのよひたしかた}} 0a681e4987acd50ea9e4575f644e4561b9ec46c5 146 115 2019-12-11T00:16:55Z 126.171.241.211 0 /* JavaScriptに変換したBCDiceを使用するツール */ wikitext text/x-wiki 本ページ以下では、様々なオンラインセッションツールから現在の[[BCDice]]をどのように呼び出しているかをまとめる。 == Rubyで書かれたBCDiceを使用するツール == === BCDiceの全機能を利用するツール === * [[/どどんとふ]] === ダイスロールのみを利用するツール === 呼び出し方の概要:[[/ダイスロールのみ利用する場合]] * [[/BCDice-API]] * [[/Onset!]] * [[/オンセンルーム]] == BCDice-APIを使用するツール == * [[Quoridorn]] ** v1.0.0b12:[https://github.com/HillTopTRPG/quoridorn-vue-cli-3/blob/bc39e134a367325a09c0e5257e5c50f9a91237a7/src/store/state_setting.ts#L51-L119 src/store/state_setting.ts#L51-L119] に呼び出す処理がある。 * [[Saipage]] ** コミット 723cbdb:[https://github.com/ysakasin/saipage/blob/723cbdbc20ad830e31dd6096bfcb39b14266bf49/client/dice.ts client/dice.ts] に呼び出す処理がある。 == JavaScriptに変換したBCDiceを使用するツール == BCDiceをOpalでJavaScriptに変換して使用する。 * [[ねこ卓]]:[https://github.com/bcdice/bcdice-js bcdice-js]を使用する。 * [[ユドナリウム]] [[Category:BCDice]] {{DEFAULTSORT:TRPGつうるからのよひたしかた}} 3e8f6758ed9e192e3e532ad868478f1b33643b4d BCDice/TRPGツールからの呼び出し方/ダイスロールのみ利用する場合 0 49 110 2019-06-27T01:32:46Z Ochaochaocha3 1 ページの作成:「[[BCDice]]のダイスロール機能のみを利用する場合の呼び出し方をまとめる。 __TOC__ == ダイスロールを行う == BCDiceのダイスロー…」 wikitext text/x-wiki [[BCDice]]のダイスロール機能のみを利用する場合の呼び出し方をまとめる。 __TOC__ == ダイスロールを行う == BCDiceのダイスロール機能を呼び出すための[[Ruby]]プログラムの概要を以下に示す。 <syntaxhighlight lang="ruby"> $LOAD_PATH.unshift('/path/to/BCDice/src') # BCDice関連ファイルを読み込む require 'bcdiceCore' require 'diceBot/DiceBot' require 'diceBot/DiceBotLoader' # ゲーム名(英数字、省略名でも可) # * 省略名の例:DX(DoubleCross)、SW20(SwordWorld2.0) game_title = 'DoubleCross' # コマンド command = '2DX+4@10' # 新しいBCDiceインスタンスを作る bcdice = BCDiceMaker.new.newBcDice # ゲームを指定する bcdice.setGameByTitle(game_title) # BCDiceに送るメッセージ(コマンド)を指定する bcdice.setMessage(command) # ダイスロールの結果(出目)を返すように設定する bcdice.setCollectRandResult(true) # ダイスロールを行い、結果を受け取る # * output:ダイスロールの結果(出目の合計など)を示すメッセージ # * secret:シークレットダイスならばtrue、そうでなければfalse output, secret = bcdice.dice_command # 出目の情報を受け取る # 2つの整数要素を持つ配列の配列として返ってくる # * 返り値の例:[[3, 10], [7, 10]](10面ダイスの3、10面ダイスの7) rolled_dice = bcdice.getRandResults </syntaxhighlight> dc555a2cbeb48804d680f84a155710a2b752d37e 111 110 2019-06-27T04:12:53Z Ochaochaocha3 1 wikitext text/x-wiki [[BCDice]]のダイスロール機能のみを利用する場合の、[[Ruby]]プログラムからの呼び出し方をまとめる。 __TOC__ == BCDice関連ファイルを読み込む == BCDiceの機能を利用する前に、1回だけ関連ファイルを読み込む必要がある。BCDiceが配置されているディレクトリを読み込みパスに追加してから、BCDice関連ファイルを読み込む。 <syntaxhighlight lang="ruby"> # BCDiceが配置されているディレクトリを読み込みパスに追加する $LOAD_PATH.unshift('/path/to/BCDice/src') # BCDice関連ファイルを読み込む require 'diceBot/DiceBot' require 'diceBot/DiceBotLoader' require 'bcdiceCore' </syntaxhighlight> == ダイスロールを行う == BCDiceのダイスロール機能を呼び出すプログラムの概要を以下に示す。 <syntaxhighlight lang="ruby"> # ゲーム名(英数字、省略名でも可) # * 省略名の例:DX(DoubleCross)、SW20(SwordWorld2.0) game_title = 'DoubleCross' # コマンド command = '2DX+4@10' # 新しいBCDiceインスタンスを作る bcdice = BCDiceMaker.new.newBcDice # ゲームを指定する bcdice.setGameByTitle(game_title) # BCDiceに送るメッセージ(コマンド)を指定する bcdice.setMessage(command) # ダイスロールの結果(出目)を返すように設定する bcdice.setCollectRandResult(true) # ダイスロールを行い、結果を受け取る # * output:ダイスロールの結果(出目の合計など)を示すメッセージ # * secret:シークレットダイスならばtrue、そうでなければfalse output, secret = bcdice.dice_command # 出目の情報を受け取る # 2つの整数要素を持つ配列の配列として返ってくる # * 返り値の例:[[3, 10], [7, 10]](10面ダイスの3、10面ダイスの7) rolled_dice = bcdice.getRandResults </syntaxhighlight> == 利用できるダイスボットの一覧を取得する == c98a8c4b56a520d6d67acadaf239c6c34450732a 112 111 2019-06-27T04:13:42Z Ochaochaocha3 1 /* ダイスロールを行う */ 例を追加する wikitext text/x-wiki [[BCDice]]のダイスロール機能のみを利用する場合の、[[Ruby]]プログラムからの呼び出し方をまとめる。 __TOC__ == BCDice関連ファイルを読み込む == BCDiceの機能を利用する前に、1回だけ関連ファイルを読み込む必要がある。BCDiceが配置されているディレクトリを読み込みパスに追加してから、BCDice関連ファイルを読み込む。 <syntaxhighlight lang="ruby"> # BCDiceが配置されているディレクトリを読み込みパスに追加する $LOAD_PATH.unshift('/path/to/BCDice/src') # BCDice関連ファイルを読み込む require 'diceBot/DiceBot' require 'diceBot/DiceBotLoader' require 'bcdiceCore' </syntaxhighlight> == ダイスロールを行う == BCDiceのダイスロール機能を呼び出すプログラムの概要を以下に示す。 <syntaxhighlight lang="ruby"> # ゲーム名(英数字、省略名でも可) # * 省略名の例:DX(DoubleCross)、SW20(SwordWorld2.0) game_title = 'DoubleCross' # コマンド command = '2DX+4@10' # 新しいBCDiceインスタンスを作る bcdice = BCDiceMaker.new.newBcDice # ゲームを指定する bcdice.setGameByTitle(game_title) # BCDiceに送るメッセージ(コマンド)を指定する bcdice.setMessage(command) # ダイスロールの結果(出目)を返すように設定する bcdice.setCollectRandResult(true) # ダイスロールを行い、結果を受け取る # * output:ダイスロールの結果(出目の合計など)を示すメッセージ # * 例:"2DX+4@10 : (2R10+4[10]) > 8[7,8]+4 > 12" # * secret:シークレットダイスならばtrue、そうでなければfalse output, secret = bcdice.dice_command # 出目の情報を受け取る # 2つの整数要素を持つ配列の配列として返ってくる # * 返り値の例:[[7, 10], [8, 10]](10面ダイスの7、10面ダイスの8) rolled_dice = bcdice.getRandResults </syntaxhighlight> == 利用できるダイスボットの一覧を取得する == a6468655a1c43655c443506e5c4a7a7a26969a1d 113 112 2019-06-27T04:14:24Z Ochaochaocha3 1 /* BCDice関連ファイルを読み込む */ wikitext text/x-wiki [[BCDice]]のダイスロール機能のみを利用する場合の、[[Ruby]]プログラムからの呼び出し方をまとめる。 __TOC__ == BCDice関連ファイルを読み込む == BCDiceの機能を利用する前に、1回だけ関連ファイルを読み込む必要がある。BCDiceが配置されているディレクトリを読み込みパスに追加してから、関連ファイルを読み込む。 <syntaxhighlight lang="ruby"> # BCDiceが配置されているディレクトリを読み込みパスに追加する $LOAD_PATH.unshift('/path/to/BCDice/src') # BCDice関連ファイルを読み込む require 'diceBot/DiceBot' require 'diceBot/DiceBotLoader' require 'bcdiceCore' </syntaxhighlight> == ダイスロールを行う == BCDiceのダイスロール機能を呼び出すプログラムの概要を以下に示す。 <syntaxhighlight lang="ruby"> # ゲーム名(英数字、省略名でも可) # * 省略名の例:DX(DoubleCross)、SW20(SwordWorld2.0) game_title = 'DoubleCross' # コマンド command = '2DX+4@10' # 新しいBCDiceインスタンスを作る bcdice = BCDiceMaker.new.newBcDice # ゲームを指定する bcdice.setGameByTitle(game_title) # BCDiceに送るメッセージ(コマンド)を指定する bcdice.setMessage(command) # ダイスロールの結果(出目)を返すように設定する bcdice.setCollectRandResult(true) # ダイスロールを行い、結果を受け取る # * output:ダイスロールの結果(出目の合計など)を示すメッセージ # * 例:"2DX+4@10 : (2R10+4[10]) > 8[7,8]+4 > 12" # * secret:シークレットダイスならばtrue、そうでなければfalse output, secret = bcdice.dice_command # 出目の情報を受け取る # 2つの整数要素を持つ配列の配列として返ってくる # * 返り値の例:[[7, 10], [8, 10]](10面ダイスの7、10面ダイスの8) rolled_dice = bcdice.getRandResults </syntaxhighlight> == 利用できるダイスボットの一覧を取得する == 56bb0971d8bc78afc1ad453d61eb1dfca5133dbf 114 113 2019-06-27T04:15:11Z Ochaochaocha3 1 /* ダイスロールを行う */ wikitext text/x-wiki [[BCDice]]のダイスロール機能のみを利用する場合の、[[Ruby]]プログラムからの呼び出し方をまとめる。 __TOC__ == BCDice関連ファイルを読み込む == BCDiceの機能を利用する前に、1回だけ関連ファイルを読み込む必要がある。BCDiceが配置されているディレクトリを読み込みパスに追加してから、関連ファイルを読み込む。 <syntaxhighlight lang="ruby"> # BCDiceが配置されているディレクトリを読み込みパスに追加する $LOAD_PATH.unshift('/path/to/BCDice/src') # BCDice関連ファイルを読み込む require 'diceBot/DiceBot' require 'diceBot/DiceBotLoader' require 'bcdiceCore' </syntaxhighlight> == ダイスロールを行う == BCDiceのダイスロール機能を呼び出すプログラムの概要を以下に示す。 <syntaxhighlight lang="ruby"> # ゲーム名(英数字。省略名でも可) # * 省略名の例:DX(DoubleCross)、SW20(SwordWorld2.0) game_title = 'DoubleCross' # コマンド command = '2DX+4@10' # 新しいBCDiceインスタンスを作る bcdice = BCDiceMaker.new.newBcDice # ゲームを指定する bcdice.setGameByTitle(game_title) # BCDiceに送るメッセージ(コマンド)を指定する bcdice.setMessage(command) # ダイスロールの結果(出目)を返すように設定する bcdice.setCollectRandResult(true) # ダイスロールを行い、結果を受け取る # * output:ダイスロールの結果(出目の合計など)を示すメッセージ # * 例:"2DX+4@10 : (2R10+4[10]) > 8[7,8]+4 > 12" # * secret:シークレットダイスならばtrue、そうでなければfalse output, secret = bcdice.dice_command # 出目の情報を受け取る # 2つの整数要素を持つ配列の配列として返ってくる # * 返り値の例:[[7, 10], [8, 10]](10面ダイスの7、10面ダイスの8) rolled_dice = bcdice.getRandResults </syntaxhighlight> == 利用できるダイスボットの一覧を取得する == 7e09b169bf5c11889c831548e8d927154479b636 116 114 2019-06-28T08:31:03Z Ochaochaocha3 1 /* 利用できるダイスボットの一覧を取得する */ wikitext text/x-wiki [[BCDice]]のダイスロール機能のみを利用する場合の、[[Ruby]]プログラムからの呼び出し方をまとめる。 __TOC__ == BCDice関連ファイルを読み込む == BCDiceの機能を利用する前に、1回だけ関連ファイルを読み込む必要がある。BCDiceが配置されているディレクトリを読み込みパスに追加してから、関連ファイルを読み込む。 <syntaxhighlight lang="ruby"> # BCDiceが配置されているディレクトリを読み込みパスに追加する $LOAD_PATH.unshift('/path/to/BCDice/src') # BCDice関連ファイルを読み込む require 'diceBot/DiceBot' require 'diceBot/DiceBotLoader' require 'bcdiceCore' </syntaxhighlight> == ダイスロールを行う == BCDiceのダイスロール機能を呼び出すプログラムの概要を以下に示す。 <syntaxhighlight lang="ruby"> # ゲーム名(英数字。省略名でも可) # * 省略名の例:DX(DoubleCross)、SW20(SwordWorld2.0) game_title = 'DoubleCross' # コマンド command = '2DX+4@10' # 新しいBCDiceインスタンスを作る bcdice = BCDiceMaker.new.newBcDice # ゲームを指定する bcdice.setGameByTitle(game_title) # BCDiceに送るメッセージ(コマンド)を指定する bcdice.setMessage(command) # ダイスロールの結果(出目)を返すように設定する bcdice.setCollectRandResult(true) # ダイスロールを行い、結果を受け取る # * output:ダイスロールの結果(出目の合計など)を示すメッセージ # * 例:"2DX+4@10 : (2R10+4[10]) > 8[7,8]+4 > 12" # * secret:シークレットダイスならばtrue、そうでなければfalse output, secret = bcdice.dice_command # 出目の情報を受け取る # 2つの整数要素を持つ配列の配列として返ってくる # * 返り値の例:[[7, 10], [8, 10]](10面ダイスの7、10面ダイスの8) rolled_dice = bcdice.getRandResults </syntaxhighlight> == 利用できるダイスボットの一覧を取得する == <code>DiceBotLoader.collectDiceBots</code> を呼び出すと、利用可能なダイスボットの配列を取得することができる。これを利用して、利用できるダイスボットの一覧を作ることができる。 <syntaxhighlight lang="ruby"> # 利用できるダイスボットの配列 dicebots = DiceBotLoader.collectDiceBots # 特定のゲームを対象としないダイスボットも一覧に加える場合 # dicebots = DiceBotLoader.collectDiceBots + [DiceBot.new] # ゲーム識別子(英数字)の配列を作る game_types = dicebots.map(&:gameType) # ゲーム名(日本語)の配列を作る game_names = dicebots.map(&:gameName) </syntaxhighlight> 67f8506bd1602059fa3d32856a1f82e5c1cc6e7e BCDice/内部処理 0 50 118 2019-06-28T13:11:51Z Ochaochaocha3 1 ページの作成:「本ページ以下では、[[BCDice]]でどのような処理が行われているかをまとめる。」 wikitext text/x-wiki 本ページ以下では、[[BCDice]]でどのような処理が行われているかをまとめる。 5df58e018e368275cf2a09c7393c792e17b1b7d3 119 118 2019-06-28T13:12:15Z Ochaochaocha3 1 カテゴリを設定する wikitext text/x-wiki 本ページ以下では、[[BCDice]]でどのような処理が行われているかをまとめる。 {{DEFAULTSORT:ないふしょり}} [[Category:BCDice]] 348dd296983d76276468d678bff3895d85e012d5 122 119 2019-06-28T13:15:25Z Ochaochaocha3 1 wikitext text/x-wiki 本ページ以下では、[[BCDice]]でどのような処理が行われているかをまとめる。 == クラス == * [[/BCDiceクラス]] * [[/BCDiceMakerクラス]] {{DEFAULTSORT:ないふしょり}} [[Category:BCDice]] 7fd57158d52e82ffabd9be5cf1dd6e82f6226825 143 122 2019-07-06T03:07:59Z Ochaochaocha3 1 /* クラス */ wikitext text/x-wiki 本ページ以下では、[[BCDice]]でどのような処理が行われているかをまとめる。 == クラス == * [[/BCDiceクラス]] * [[/BCDiceMakerクラス]] * [[/AddDiceクラス]]:加算ロールの演算 {{DEFAULTSORT:ないふしょり}} [[Category:BCDice]] 299241350e428b801cd0384c310529433197084b BCDice/TRPGツールからの呼び出し方/BCDice-API 0 17 120 41 2019-06-28T13:12:48Z Ochaochaocha3 1 読みを設定する wikitext text/x-wiki [[BCDice-API]]からの[[BCDice]]の呼び出し方。[https://github.com/ysakasin/bcdice-api/releases/tag/0.6.2 v0.6.2]のソースコードを参考にしている。 == server.rb L74-L78 == https://github.com/ysakasin/bcdice-api/blob/0dfd095a4c7befed58ffbb7eb880a9d729badf2a/server.rb#L74-L78 パス `/v1/diceroll` にリクエストが来たときの処理。ダイスロールを行う。 <syntaxhighlight lang="ruby"> get "/v1/diceroll" do result, secret, dices = diceroll(params[:system], params[:command]) jsonp ok: true, result: result, secret: secret, dices: dices end </syntaxhighlight> == server.rb L20-L42 == https://github.com/ysakasin/bcdice-api/blob/0dfd095a4c7befed58ffbb7eb880a9d729badf2a/server.rb#L20-L42 ダイスロールを行うメソッド。 <syntaxhighlight lang="ruby"> def diceroll(system, command) dicebot = BCDice::DICEBOTS[system] if dicebot.nil? raise UnsupportedDicebot end if command.nil? || command.empty? raise CommandError end bcdice = BCDiceMaker.new.newBcDice bcdice.setDiceBot(dicebot) bcdice.setMessage(command) bcdice.setCollectRandResult(true) result, secret = bcdice.dice_command dices = bcdice.getRandResults.map {|dice| {faces: dice[1], value: dice[0]}} if result.nil? raise CommandError end return result, secret, dices end </syntaxhighlight> {{DEFAULTSORT:BCDice API}} [[Category:BCDice/TRPGツールからの呼び出し方]] 886608273f763972c208044ca06bc9fe6ac1d6a4 BCDice/TRPGツールからの呼び出し方/Onset! 0 21 121 45 2019-06-28T13:13:08Z Ochaochaocha3 1 読みを設定する wikitext text/x-wiki [[Onset!]]からの[[BCDice]]の呼び出し方。[https://github.com/kiridaruma/Onset/releases/tag/v2.1.3 v2.1.3]のソースコードを参考にしている。 ツール本体は[[PHP]]製だが、[[Ruby]]で書かれた簡潔なラッパースクリプトを[[CGI]]で呼び出している。 __TOC__ == Onset/public_html/bcdice/roll.rb L31-L36 == https://github.com/kiridaruma/Onset/blob/297e66de6b799198cdf17036e12f89c7506fcd65/Onset/public_html/bcdice/roll.rb#L31-L36 クエリパラメータ <code>list=1</code> がついていた場合、ゲームシステム一覧を出力する。 <syntaxhighlight lang="ruby"> if(params['list'][0] == "1") $allGameTypes.each do |var| puts var + "\n" end exit end </syntaxhighlight> == Onset/public_html/bcdice/roll.rb L47-L55 == https://github.com/kiridaruma/Onset/blob/297e66de6b799198cdf17055e12f89c7506fcd65/Onset/public_html/bcdice/roll.rb#L47-L55 ダイスロールを行う。 <syntaxhighlight lang="ruby"> bcmaker = OnsetBCDiceMaker.new bcdice = bcmaker.newBcDice() bcdice.setGameByTitle(params['sys'][0]) bcdice.setMessage(params['text'][0]) bcdice.setNick('onset') hoge, foo = bcdice.dice_command puts hoge </syntaxhighlight> == Onset/public_html/bcdice/roll.rb L11-L24 == https://github.com/kiridaruma/Onset/blob/297e66de6b799198cdf17055e12f89c7506fcd65/Onset/public_html/bcdice/roll.rb#L11-L24 <code>OnsetBCDice</code> クラスは、Onset!のインターフェースに合わせてニックネームを設定する機能を付加している。<code>OnsetBCDiceMaker</code> クラスは、BCDiceのインスタンス作成時に <code>OnsetBCDice</code> クラスを使うようにする。 <syntaxhighlight lang="ruby"> class OnsetBCDiceMaker < BCDiceMaker def newBcDice bcdice = OnsetBCDice.new(self, @cardTrader, @diceBot, @counterInfos, @tableFileData) return bcdice end end class OnsetBCDice < BCDice def setNick(nick) @nick_e = nick end end </syntaxhighlight> {{DEFAULTSORT:Onset}} [[Category:BCDice/TRPGツールからの呼び出し方]] 51a8b38e159a5ee003b75f2b000b634a40b093e2 BCDice/内部処理/BCDiceクラス 0 51 123 2019-06-28T13:25:23Z Ochaochaocha3 1 ページの作成:「BCDiceの司令塔といえるクラス。ゲームの指定、ダイスロールなどの主要な操作は、このクラスを介して行う。 * v2.02.80.01:https…」 wikitext text/x-wiki BCDiceの司令塔といえるクラス。ゲームの指定、ダイスロールなどの主要な操作は、このクラスを介して行う。 * v2.02.80.01:https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb == setGameByTitle == {{DEFAULTSORT:BCDice くらす}} [[Category:BCDice/内部処理]] 5c8fb1b4399b7dbadd86d23587840c31e409c3c1 124 123 2019-06-28T14:56:51Z Ochaochaocha3 1 /* setGameByTitle */ wikitext text/x-wiki BCDiceの司令塔といえるクラス。ゲームの指定、ダイスロールなどの主要な操作は、このクラスを介して行う。 * v2.02.80.01:https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb == setGameByTitle == https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb#L1778-L1801 # カード機能を初期化する。 # 指定されたゲーム名のダイスボットを設定する。 ## 設定後の処理を行う(<code>diceBot.postSet</code>)。 # ゲームを設定したことを示すメッセージを返す。 <syntaxhighlight lang="ruby"> # 指定したタイトルのゲームを設定する # @param [String] gameTitle ゲームタイトル # @return [String] ゲームを設定したことを示すメッセージ def setGameByTitle(gameTitle) debug('setGameByTitle gameTitle', gameTitle) @cardTrader.initValues loader = DiceBotLoaderList.find(gameTitle) diceBot = if loader loader.loadDiceBot else DiceBotLoader.loadUnknownGame(gameTitle) || DiceBot.new end setDiceBot(diceBot) diceBot.postSet message = "Game設定を#{diceBot.gameName}に設定しました" debug( 'setGameByTitle message', message ) return message end </syntaxhighlight> {{DEFAULTSORT:BCDice くらす}} [[Category:BCDice/内部処理]] 42b632050b1378b78e3df669a9159eef784e6920 125 124 2019-06-28T14:57:36Z Ochaochaocha3 1 目次を追加する wikitext text/x-wiki BCDiceの司令塔といえるクラス。ゲームの指定、ダイスロールなどの主要な操作は、このクラスを介して行う。 * v2.02.80.01:https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb __TOC__ == setGameByTitle == https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb#L1778-L1801 # カード機能を初期化する。 # 指定されたゲーム名のダイスボットを設定する。 ## 設定後の処理を行う(<code>diceBot.postSet</code>)。 # ゲームを設定したことを示すメッセージを返す。 <syntaxhighlight lang="ruby"> # 指定したタイトルのゲームを設定する # @param [String] gameTitle ゲームタイトル # @return [String] ゲームを設定したことを示すメッセージ def setGameByTitle(gameTitle) debug('setGameByTitle gameTitle', gameTitle) @cardTrader.initValues loader = DiceBotLoaderList.find(gameTitle) diceBot = if loader loader.loadDiceBot else DiceBotLoader.loadUnknownGame(gameTitle) || DiceBot.new end setDiceBot(diceBot) diceBot.postSet message = "Game設定を#{diceBot.gameName}に設定しました" debug( 'setGameByTitle message', message ) return message end </syntaxhighlight> {{DEFAULTSORT:BCDice くらす}} [[Category:BCDice/内部処理]] 51d948aa5091b340fb5f817f2822bb53d0a57d47 126 125 2019-06-28T16:21:46Z Ochaochaocha3 1 /* setMessage */ wikitext text/x-wiki BCDiceの司令塔といえるクラス。ゲームの指定、ダイスロールなどの主要な操作は、このクラスを介して行う。 * v2.02.80.01:https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb __TOC__ == setGameByTitle == https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb#L1778-L1801 # カード機能を初期化する。 # 指定されたゲーム名のダイスボットを設定する。 ## 設定後の処理を行う(<code>diceBot.postSet</code>)。 # ゲームを設定したことを示すメッセージを返す。 <syntaxhighlight lang="ruby"> # 指定したタイトルのゲームを設定する # @param [String] gameTitle ゲームタイトル # @return [String] ゲームを設定したことを示すメッセージ def setGameByTitle(gameTitle) debug('setGameByTitle gameTitle', gameTitle) @cardTrader.initValues loader = DiceBotLoaderList.find(gameTitle) diceBot = if loader loader.loadDiceBot else DiceBotLoader.loadUnknownGame(gameTitle) || DiceBot.new end setDiceBot(diceBot) diceBot.postSet message = "Game設定を#{diceBot.gameName}に設定しました" debug( 'setGameByTitle message', message ) return message end </syntaxhighlight> == setMessage == https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb#L146-L163 ダイスボットに実行させるメッセージを設定する。 # メッセージのパターンに合わせて指定されたメッセージを加工する。 #* `Open Dice!` や `Open Plot!`、`Set` 系は指定されたメッセージそのまま。 #* それ以外の場合、空白の前まで。 # 括弧内前処理を行う。「[[#parren_killer]]」を参照。結果を `@messageOriginal` に記録する。 # 括弧内前処理の結果に対して、アルファベットを大文字にする。これを次に実行させるメッセージとして `@message` に記録する。 <syntaxhighlight lang="ruby"> def setMessage(message) # 設定で変化し得るためopen系はここで正規表現を作る openPattern = /\A\s*(?:#{$OPEN_DICE}|#{$OPEN_PLOT})\s*\z/i messageToSet = case message when openPattern, SET_COMMAND_PATTERN message else # 空白が含まれる場合、最初の部分だけを取り出す message.split(/\s/, 2).first end debug("setMessage messageToSet", messageToSet) @messageOriginal = parren_killer(messageToSet) @message = @messageOriginal.upcase debug("@message", @message) end </syntaxhighlight> {{DEFAULTSORT:BCDice くらす}} [[Category:BCDice/内部処理]] 1c68471afed34c285776dccd53b3d4dfd3c0bef9 127 126 2019-06-28T16:22:23Z Ochaochaocha3 1 /* setMessage */ code wikitext text/x-wiki BCDiceの司令塔といえるクラス。ゲームの指定、ダイスロールなどの主要な操作は、このクラスを介して行う。 * v2.02.80.01:https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb __TOC__ == setGameByTitle == https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb#L1778-L1801 # カード機能を初期化する。 # 指定されたゲーム名のダイスボットを設定する。 ## 設定後の処理を行う(<code>diceBot.postSet</code>)。 # ゲームを設定したことを示すメッセージを返す。 <syntaxhighlight lang="ruby"> # 指定したタイトルのゲームを設定する # @param [String] gameTitle ゲームタイトル # @return [String] ゲームを設定したことを示すメッセージ def setGameByTitle(gameTitle) debug('setGameByTitle gameTitle', gameTitle) @cardTrader.initValues loader = DiceBotLoaderList.find(gameTitle) diceBot = if loader loader.loadDiceBot else DiceBotLoader.loadUnknownGame(gameTitle) || DiceBot.new end setDiceBot(diceBot) diceBot.postSet message = "Game設定を#{diceBot.gameName}に設定しました" debug( 'setGameByTitle message', message ) return message end </syntaxhighlight> == setMessage == https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb#L146-L163 ダイスボットに実行させるメッセージを設定する。 # メッセージのパターンに合わせて指定されたメッセージを加工する。 #* <code>Open Dice!</code> や <code>Open Plot!</code>、<code>Set</code> 系は指定されたメッセージそのまま。 #* それ以外の場合、空白の前まで。 # 括弧内前処理を行う。「[[#parren_killer]]」を参照。結果を `@messageOriginal` に記録する。 # 括弧内前処理の結果に対して、アルファベットを大文字にする。これを次に実行させるメッセージとして `@message` に記録する。 <syntaxhighlight lang="ruby"> def setMessage(message) # 設定で変化し得るためopen系はここで正規表現を作る openPattern = /\A\s*(?:#{$OPEN_DICE}|#{$OPEN_PLOT})\s*\z/i messageToSet = case message when openPattern, SET_COMMAND_PATTERN message else # 空白が含まれる場合、最初の部分だけを取り出す message.split(/\s/, 2).first end debug("setMessage messageToSet", messageToSet) @messageOriginal = parren_killer(messageToSet) @message = @messageOriginal.upcase debug("@message", @message) end </syntaxhighlight> {{DEFAULTSORT:BCDice くらす}} [[Category:BCDice/内部処理]] 68502cd9830403c4feaeff86da01fcf2f6fb74bc 128 127 2019-06-28T16:25:02Z Ochaochaocha3 1 /* setGameByTitle */ wikitext text/x-wiki BCDiceの司令塔といえるクラス。ゲームの指定、ダイスロールなどの主要な操作は、このクラスを介して行う。 * v2.02.80.01:https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb __TOC__ == setGameByTitle == https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb#L1778-L1801 指定されたゲーム名のダイスボットを使うように設定する。 # カード機能を初期化する。 # 指定されたゲーム名のダイスボットを設定する。 ## 設定後の処理を行う(<code>diceBot.postSet</code>)。 # ゲームを設定したことを示すメッセージを返す。 <syntaxhighlight lang="ruby"> # 指定したタイトルのゲームを設定する # @param [String] gameTitle ゲームタイトル # @return [String] ゲームを設定したことを示すメッセージ def setGameByTitle(gameTitle) debug('setGameByTitle gameTitle', gameTitle) @cardTrader.initValues loader = DiceBotLoaderList.find(gameTitle) diceBot = if loader loader.loadDiceBot else DiceBotLoader.loadUnknownGame(gameTitle) || DiceBot.new end setDiceBot(diceBot) diceBot.postSet message = "Game設定を#{diceBot.gameName}に設定しました" debug( 'setGameByTitle message', message ) return message end </syntaxhighlight> == setMessage == https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb#L146-L163 ダイスボットに実行させるメッセージを設定する。 # メッセージのパターンに合わせて指定されたメッセージを加工する。 #* <code>Open Dice!</code> や <code>Open Plot!</code>、<code>Set</code> 系は指定されたメッセージそのまま。 #* それ以外の場合、空白の前まで。 # 括弧内前処理を行う。「[[#parren_killer]]」を参照。結果を `@messageOriginal` に記録する。 # 括弧内前処理の結果に対して、アルファベットを大文字にする。これを次に実行させるメッセージとして `@message` に記録する。 <syntaxhighlight lang="ruby"> def setMessage(message) # 設定で変化し得るためopen系はここで正規表現を作る openPattern = /\A\s*(?:#{$OPEN_DICE}|#{$OPEN_PLOT})\s*\z/i messageToSet = case message when openPattern, SET_COMMAND_PATTERN message else # 空白が含まれる場合、最初の部分だけを取り出す message.split(/\s/, 2).first end debug("setMessage messageToSet", messageToSet) @messageOriginal = parren_killer(messageToSet) @message = @messageOriginal.upcase debug("@message", @message) end </syntaxhighlight> {{DEFAULTSORT:BCDice くらす}} [[Category:BCDice/内部処理]] 1a77dd27c5ef2e8ab78cf8baedc291e53ce23956 129 128 2019-06-28T16:25:38Z Ochaochaocha3 1 /* setMessage */ code wikitext text/x-wiki BCDiceの司令塔といえるクラス。ゲームの指定、ダイスロールなどの主要な操作は、このクラスを介して行う。 * v2.02.80.01:https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb __TOC__ == setGameByTitle == https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb#L1778-L1801 指定されたゲーム名のダイスボットを使うように設定する。 # カード機能を初期化する。 # 指定されたゲーム名のダイスボットを設定する。 ## 設定後の処理を行う(<code>diceBot.postSet</code>)。 # ゲームを設定したことを示すメッセージを返す。 <syntaxhighlight lang="ruby"> # 指定したタイトルのゲームを設定する # @param [String] gameTitle ゲームタイトル # @return [String] ゲームを設定したことを示すメッセージ def setGameByTitle(gameTitle) debug('setGameByTitle gameTitle', gameTitle) @cardTrader.initValues loader = DiceBotLoaderList.find(gameTitle) diceBot = if loader loader.loadDiceBot else DiceBotLoader.loadUnknownGame(gameTitle) || DiceBot.new end setDiceBot(diceBot) diceBot.postSet message = "Game設定を#{diceBot.gameName}に設定しました" debug( 'setGameByTitle message', message ) return message end </syntaxhighlight> == setMessage == https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb#L146-L163 ダイスボットに実行させるメッセージを設定する。 # メッセージのパターンに合わせて指定されたメッセージを加工する。 #* <code>Open Dice!</code> や <code>Open Plot!</code>、<code>Set</code> 系は指定されたメッセージそのまま。 #* それ以外の場合、空白の前まで。 # 括弧内前処理を行う。「[[#parren_killer]]」を参照。結果を <code>@messageOriginal</code> に記録する。 # 括弧内前処理の結果に対して、アルファベットを大文字にする。これを次に実行させるメッセージとして <code>@message</code> に記録する。 <syntaxhighlight lang="ruby"> def setMessage(message) # 設定で変化し得るためopen系はここで正規表現を作る openPattern = /\A\s*(?:#{$OPEN_DICE}|#{$OPEN_PLOT})\s*\z/i messageToSet = case message when openPattern, SET_COMMAND_PATTERN message else # 空白が含まれる場合、最初の部分だけを取り出す message.split(/\s/, 2).first end debug("setMessage messageToSet", messageToSet) @messageOriginal = parren_killer(messageToSet) @message = @messageOriginal.upcase debug("@message", @message) end </syntaxhighlight> {{DEFAULTSORT:BCDice くらす}} [[Category:BCDice/内部処理]] b9615699dd73328fe8eb09d3f1a25537d322c5d6 130 129 2019-06-28T16:40:48Z Ochaochaocha3 1 /* parren_killer */ wikitext text/x-wiki BCDiceの司令塔といえるクラス。ゲームの指定、ダイスロールなどの主要な操作は、このクラスを介して行う。 * v2.02.80.01:https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb __TOC__ == setGameByTitle == https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb#L1778-L1801 指定されたゲーム名のダイスボットを使うように設定する。 # カード機能を初期化する。 # 指定されたゲーム名のダイスボットを設定する。 ## 設定後の処理を行う(<code>diceBot.postSet</code>)。 # ゲームを設定したことを示すメッセージを返す。 <syntaxhighlight lang="ruby"> # 指定したタイトルのゲームを設定する # @param [String] gameTitle ゲームタイトル # @return [String] ゲームを設定したことを示すメッセージ def setGameByTitle(gameTitle) debug('setGameByTitle gameTitle', gameTitle) @cardTrader.initValues loader = DiceBotLoaderList.find(gameTitle) diceBot = if loader loader.loadDiceBot else DiceBotLoader.loadUnknownGame(gameTitle) || DiceBot.new end setDiceBot(diceBot) diceBot.postSet message = "Game設定を#{diceBot.gameName}に設定しました" debug( 'setGameByTitle message', message ) return message end </syntaxhighlight> == setMessage == https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb#L146-L163 ダイスボットに実行させるメッセージを設定する。 # メッセージのパターンに合わせて指定されたメッセージを加工する。 #* <code>Open Dice!</code> や <code>Open Plot!</code>、<code>Set</code> 系は指定されたメッセージそのまま。 #* それ以外の場合、空白の前まで。 # 括弧内前処理を行う。「[[#parren_killer]]」を参照。結果を <code>@messageOriginal</code> に記録する。 # 括弧内前処理の結果に対して、アルファベットを大文字にする。これを次に実行させるメッセージとして <code>@message</code> に記録する。 <syntaxhighlight lang="ruby"> def setMessage(message) # 設定で変化し得るためopen系はここで正規表現を作る openPattern = /\A\s*(?:#{$OPEN_DICE}|#{$OPEN_PLOT})\s*\z/i messageToSet = case message when openPattern, SET_COMMAND_PATTERN message else # 空白が含まれる場合、最初の部分だけを取り出す message.split(/\s/, 2).first end debug("setMessage messageToSet", messageToSet) @messageOriginal = parren_killer(messageToSet) @message = @messageOriginal.upcase debug("@message", @message) end </syntaxhighlight> == parren_killer == https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb#L1550-L1608 括弧内前処理、つまり括弧で囲まれた数式部分を還元して整数に変える処理。 BCDiceのダイス構文は正規文法ではないのに、正規表現だけで処理しようとしているため、無理矢理気味な処理となっている。また、原理上、文法エラーを検出できない場合がある。例えば、 * <code>(2*/2)d6</code> → <code>(2*/2)d6 : (1D6) > 3</code> など。 <syntaxhighlight lang="ruby"> def parren_killer(string) debug("parren_killer input", string) while( /^(.*?)\[(\d+[Dd]\d+)\](.*)/ =~ string ) str_before = "" str_after = "" dice_cmd = $2 str_before = $1 if($1) str_after = $3 if($3) rolled, dmy = rollDiceAddingUp(dice_cmd) string = "#{str_before}#{rolled}#{str_after}" end string = changeRangeTextToNumberText(string) while(/^(.*?)(\([\d\/*+-]+?\))(.*)/ =~ string) debug("while string", string) str_a = $3 str_a ||= "" str_b = $1 str_b ||= "" debug("str_b", str_b) par_i = $2 debug("par_i", par_i) par_o = paren_k(par_i) debug("par_o", par_o) if(par_o != 0) if(par_o < 0) if(/(.+?)(\+)$/ =~ str_b) str_b = $1 elsif(/(.+?)(-)$/ =~ str_b) str_b = "#{$1}+" par_o = par_o * -1 end end string = "#{str_b}#{par_o}#{str_a}" else if(/^([DBRUdbru][\d]+)(.*)/ =~ $str_a) str_a = $2 end string = "#{str_b}0#{str_a}" end end debug("diceBot.changeText(string) begin", string) string = @diceBot.changeText(string) debug("diceBot.changeText(string) end", string) string = string.gsub(/([\d]+[dD])([^\d\w]|$)/) {"#{$1}6#{$2}"} debug("parren_killer output", string) return string end </syntaxhighlight> {{DEFAULTSORT:BCDice くらす}} [[Category:BCDice/内部処理]] 0f6307fc7802d733b51cb95856acb45641e658c9 131 130 2019-06-30T17:50:35Z Ochaochaocha3 1 /* parren_killer */ 処理の流れ wikitext text/x-wiki BCDiceの司令塔といえるクラス。ゲームの指定、ダイスロールなどの主要な操作は、このクラスを介して行う。 * v2.02.80.01:https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb __TOC__ == setGameByTitle == https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb#L1778-L1801 指定されたゲーム名のダイスボットを使うように設定する。 # カード機能を初期化する。 # 指定されたゲーム名のダイスボットを設定する。 ## 設定後の処理を行う(<code>diceBot.postSet</code>)。 # ゲームを設定したことを示すメッセージを返す。 <syntaxhighlight lang="ruby"> # 指定したタイトルのゲームを設定する # @param [String] gameTitle ゲームタイトル # @return [String] ゲームを設定したことを示すメッセージ def setGameByTitle(gameTitle) debug('setGameByTitle gameTitle', gameTitle) @cardTrader.initValues loader = DiceBotLoaderList.find(gameTitle) diceBot = if loader loader.loadDiceBot else DiceBotLoader.loadUnknownGame(gameTitle) || DiceBot.new end setDiceBot(diceBot) diceBot.postSet message = "Game設定を#{diceBot.gameName}に設定しました" debug( 'setGameByTitle message', message ) return message end </syntaxhighlight> == setMessage == https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb#L146-L163 ダイスボットに実行させるメッセージを設定する。 # メッセージのパターンに合わせて指定されたメッセージを加工する。 #* <code>Open Dice!</code> や <code>Open Plot!</code>、<code>Set</code> 系は指定されたメッセージそのまま。 #* それ以外の場合、空白の前まで。 # 括弧内前処理を行う。「[[#parren_killer]]」を参照。結果を <code>@messageOriginal</code> に記録する。 # 括弧内前処理の結果に対して、アルファベットを大文字にする。これを次に実行させるメッセージとして <code>@message</code> に記録する。 <syntaxhighlight lang="ruby"> def setMessage(message) # 設定で変化し得るためopen系はここで正規表現を作る openPattern = /\A\s*(?:#{$OPEN_DICE}|#{$OPEN_PLOT})\s*\z/i messageToSet = case message when openPattern, SET_COMMAND_PATTERN message else # 空白が含まれる場合、最初の部分だけを取り出す message.split(/\s/, 2).first end debug("setMessage messageToSet", messageToSet) @messageOriginal = parren_killer(messageToSet) @message = @messageOriginal.upcase debug("@message", @message) end </syntaxhighlight> == parren_killer == https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb#L1550-L1608 括弧内前処理、つまり括弧で囲まれた数式部分を還元して整数に変える処理。 BCDiceのダイス構文は正規文法ではないのに、正規表現だけで処理しようとしているため、無理矢理気味な処理となっている。また、原理上、文法エラーを検出できない場合がある。例えば、 * <code>(2*/2)d6</code> → <code>(2*/2)d6 : (1D6) > 3</code> など。 処理の流れは以下のとおり。 # <code>[<var>n</var>D<var>s</var>]</code> の加算ロールを先に実行する。実際の処理は「[[#rollDiceAddingUp]]」が担当する。 # 範囲構文を数字に変える。「[[#changeRangeTextToNumberText]]」を参照。 # 括弧に入った四則演算(<code>+-*/</code>)を処理する。 # <code><var>n</var>D</code> が残っていたら、<code><var>n</var>D6</code> に変える。 <syntaxhighlight lang="ruby"> def parren_killer(string) debug("parren_killer input", string) while( /^(.*?)\[(\d+[Dd]\d+)\](.*)/ =~ string ) str_before = "" str_after = "" dice_cmd = $2 str_before = $1 if($1) str_after = $3 if($3) rolled, dmy = rollDiceAddingUp(dice_cmd) string = "#{str_before}#{rolled}#{str_after}" end string = changeRangeTextToNumberText(string) while(/^(.*?)(\([\d\/*+-]+?\))(.*)/ =~ string) debug("while string", string) str_a = $3 str_a ||= "" str_b = $1 str_b ||= "" debug("str_b", str_b) par_i = $2 debug("par_i", par_i) par_o = paren_k(par_i) debug("par_o", par_o) if(par_o != 0) if(par_o < 0) if(/(.+?)(\+)$/ =~ str_b) str_b = $1 elsif(/(.+?)(-)$/ =~ str_b) str_b = "#{$1}+" par_o = par_o * -1 end end string = "#{str_b}#{par_o}#{str_a}" else if(/^([DBRUdbru][\d]+)(.*)/ =~ $str_a) str_a = $2 end string = "#{str_b}0#{str_a}" end end debug("diceBot.changeText(string) begin", string) string = @diceBot.changeText(string) debug("diceBot.changeText(string) end", string) string = string.gsub(/([\d]+[dD])([^\d\w]|$)/) {"#{$1}6#{$2}"} debug("parren_killer output", string) return string end </syntaxhighlight> {{DEFAULTSORT:BCDice くらす}} [[Category:BCDice/内部処理]] 0c7ed231de4b4c3f9e2f90d59177a6abf187e0e9 132 131 2019-07-01T14:44:32Z Ochaochaocha3 1 /* setCollectRandResult */ wikitext text/x-wiki BCDiceの司令塔といえるクラス。ゲームの指定、ダイスロールなどの主要な操作は、このクラスを介して行う。 * v2.02.80.01:https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb __TOC__ == setGameByTitle == https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb#L1778-L1801 指定されたゲーム名のダイスボットを使うように設定する。 # カード機能を初期化する。 # 指定されたゲーム名のダイスボットを設定する。 ## 設定後の処理を行う(<code>diceBot.postSet</code>)。 # ゲームを設定したことを示すメッセージを返す。 <syntaxhighlight lang="ruby"> # 指定したタイトルのゲームを設定する # @param [String] gameTitle ゲームタイトル # @return [String] ゲームを設定したことを示すメッセージ def setGameByTitle(gameTitle) debug('setGameByTitle gameTitle', gameTitle) @cardTrader.initValues loader = DiceBotLoaderList.find(gameTitle) diceBot = if loader loader.loadDiceBot else DiceBotLoader.loadUnknownGame(gameTitle) || DiceBot.new end setDiceBot(diceBot) diceBot.postSet message = "Game設定を#{diceBot.gameName}に設定しました" debug( 'setGameByTitle message', message ) return message end </syntaxhighlight> == setMessage == https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb#L146-L163 ダイスボットに実行させるメッセージを設定する。 # メッセージのパターンに合わせて指定されたメッセージを加工する。 #* <code>Open Dice!</code> や <code>Open Plot!</code>、<code>Set</code> 系は指定されたメッセージそのまま。 #* それ以外の場合、空白の前まで。 # 括弧内前処理を行う。「[[#parren_killer]]」を参照。結果を <code>@messageOriginal</code> に記録する。 # 括弧内前処理の結果に対して、アルファベットを大文字にする。これを次に実行させるメッセージとして <code>@message</code> に記録する。 <syntaxhighlight lang="ruby"> def setMessage(message) # 設定で変化し得るためopen系はここで正規表現を作る openPattern = /\A\s*(?:#{$OPEN_DICE}|#{$OPEN_PLOT})\s*\z/i messageToSet = case message when openPattern, SET_COMMAND_PATTERN message else # 空白が含まれる場合、最初の部分だけを取り出す message.split(/\s/, 2).first end debug("setMessage messageToSet", messageToSet) @messageOriginal = parren_killer(messageToSet) @message = @messageOriginal.upcase debug("@message", @message) end </syntaxhighlight> == parren_killer == https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb#L1550-L1608 括弧内前処理、つまり括弧で囲まれた数式部分を還元して整数に変える処理。 BCDiceのダイス構文は正規文法ではないのに、正規表現だけで処理しようとしているため、無理矢理気味な処理となっている。また、原理上、文法エラーを検出できない場合がある。例えば、 * <code>(2*/2)d6</code> → <code>(2*/2)d6 : (1D6) > 3</code> など。 処理の流れは以下のとおり。 # <code>[<var>n</var>D<var>s</var>]</code> の加算ロールを先に実行する。実際の処理は「[[#rollDiceAddingUp]]」が担当する。 # 範囲構文を数字に変える。「[[#changeRangeTextToNumberText]]」を参照。 # 括弧に入った四則演算(<code>+-*/</code>)を処理する。 # <code><var>n</var>D</code> が残っていたら、<code><var>n</var>D6</code> に変える。 <syntaxhighlight lang="ruby"> def parren_killer(string) debug("parren_killer input", string) while( /^(.*?)\[(\d+[Dd]\d+)\](.*)/ =~ string ) str_before = "" str_after = "" dice_cmd = $2 str_before = $1 if($1) str_after = $3 if($3) rolled, dmy = rollDiceAddingUp(dice_cmd) string = "#{str_before}#{rolled}#{str_after}" end string = changeRangeTextToNumberText(string) while(/^(.*?)(\([\d\/*+-]+?\))(.*)/ =~ string) debug("while string", string) str_a = $3 str_a ||= "" str_b = $1 str_b ||= "" debug("str_b", str_b) par_i = $2 debug("par_i", par_i) par_o = paren_k(par_i) debug("par_o", par_o) if(par_o != 0) if(par_o < 0) if(/(.+?)(\+)$/ =~ str_b) str_b = $1 elsif(/(.+?)(-)$/ =~ str_b) str_b = "#{$1}+" par_o = par_o * -1 end end string = "#{str_b}#{par_o}#{str_a}" else if(/^([DBRUdbru][\d]+)(.*)/ =~ $str_a) str_a = $2 end string = "#{str_b}0#{str_a}" end end debug("diceBot.changeText(string) begin", string) string = @diceBot.changeText(string) debug("diceBot.changeText(string) end", string) string = string.gsub(/([\d]+[dD])([^\d\w]|$)/) {"#{$1}6#{$2}"} debug("parren_killer output", string) return string end </syntaxhighlight> ## setCollectRandResult https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb#L1046-L1052 出目を記録するかどうかを設定するメソッドのようだが、実際には、引数 <code>b</code> に <code>true</code> を設定すると記録スロットを初期化するという動作になっている。<code>false</code> を設定すると記録スロットが <code>nil</code> でクリアされる。 <syntaxhighlight lang="ruby"> def setCollectRandResult(b) if( b ) @randResults = [] else @randResults = nil end end </syntaxhighlight> {{DEFAULTSORT:BCDice くらす}} [[Category:BCDice/内部処理]] 41b5a91e1f4c10bf7c810c67c74c2f3ab726f6a9 133 132 2019-07-01T14:44:55Z Ochaochaocha3 1 /* setCollectRandResult */ wikitext text/x-wiki BCDiceの司令塔といえるクラス。ゲームの指定、ダイスロールなどの主要な操作は、このクラスを介して行う。 * v2.02.80.01:https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb __TOC__ == setGameByTitle == https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb#L1778-L1801 指定されたゲーム名のダイスボットを使うように設定する。 # カード機能を初期化する。 # 指定されたゲーム名のダイスボットを設定する。 ## 設定後の処理を行う(<code>diceBot.postSet</code>)。 # ゲームを設定したことを示すメッセージを返す。 <syntaxhighlight lang="ruby"> # 指定したタイトルのゲームを設定する # @param [String] gameTitle ゲームタイトル # @return [String] ゲームを設定したことを示すメッセージ def setGameByTitle(gameTitle) debug('setGameByTitle gameTitle', gameTitle) @cardTrader.initValues loader = DiceBotLoaderList.find(gameTitle) diceBot = if loader loader.loadDiceBot else DiceBotLoader.loadUnknownGame(gameTitle) || DiceBot.new end setDiceBot(diceBot) diceBot.postSet message = "Game設定を#{diceBot.gameName}に設定しました" debug( 'setGameByTitle message', message ) return message end </syntaxhighlight> == setMessage == https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb#L146-L163 ダイスボットに実行させるメッセージを設定する。 # メッセージのパターンに合わせて指定されたメッセージを加工する。 #* <code>Open Dice!</code> や <code>Open Plot!</code>、<code>Set</code> 系は指定されたメッセージそのまま。 #* それ以外の場合、空白の前まで。 # 括弧内前処理を行う。「[[#parren_killer]]」を参照。結果を <code>@messageOriginal</code> に記録する。 # 括弧内前処理の結果に対して、アルファベットを大文字にする。これを次に実行させるメッセージとして <code>@message</code> に記録する。 <syntaxhighlight lang="ruby"> def setMessage(message) # 設定で変化し得るためopen系はここで正規表現を作る openPattern = /\A\s*(?:#{$OPEN_DICE}|#{$OPEN_PLOT})\s*\z/i messageToSet = case message when openPattern, SET_COMMAND_PATTERN message else # 空白が含まれる場合、最初の部分だけを取り出す message.split(/\s/, 2).first end debug("setMessage messageToSet", messageToSet) @messageOriginal = parren_killer(messageToSet) @message = @messageOriginal.upcase debug("@message", @message) end </syntaxhighlight> == parren_killer == https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb#L1550-L1608 括弧内前処理、つまり括弧で囲まれた数式部分を還元して整数に変える処理。 BCDiceのダイス構文は正規文法ではないのに、正規表現だけで処理しようとしているため、無理矢理気味な処理となっている。また、原理上、文法エラーを検出できない場合がある。例えば、 * <code>(2*/2)d6</code> → <code>(2*/2)d6 : (1D6) > 3</code> など。 処理の流れは以下のとおり。 # <code>[<var>n</var>D<var>s</var>]</code> の加算ロールを先に実行する。実際の処理は「[[#rollDiceAddingUp]]」が担当する。 # 範囲構文を数字に変える。「[[#changeRangeTextToNumberText]]」を参照。 # 括弧に入った四則演算(<code>+-*/</code>)を処理する。 # <code><var>n</var>D</code> が残っていたら、<code><var>n</var>D6</code> に変える。 <syntaxhighlight lang="ruby"> def parren_killer(string) debug("parren_killer input", string) while( /^(.*?)\[(\d+[Dd]\d+)\](.*)/ =~ string ) str_before = "" str_after = "" dice_cmd = $2 str_before = $1 if($1) str_after = $3 if($3) rolled, dmy = rollDiceAddingUp(dice_cmd) string = "#{str_before}#{rolled}#{str_after}" end string = changeRangeTextToNumberText(string) while(/^(.*?)(\([\d\/*+-]+?\))(.*)/ =~ string) debug("while string", string) str_a = $3 str_a ||= "" str_b = $1 str_b ||= "" debug("str_b", str_b) par_i = $2 debug("par_i", par_i) par_o = paren_k(par_i) debug("par_o", par_o) if(par_o != 0) if(par_o < 0) if(/(.+?)(\+)$/ =~ str_b) str_b = $1 elsif(/(.+?)(-)$/ =~ str_b) str_b = "#{$1}+" par_o = par_o * -1 end end string = "#{str_b}#{par_o}#{str_a}" else if(/^([DBRUdbru][\d]+)(.*)/ =~ $str_a) str_a = $2 end string = "#{str_b}0#{str_a}" end end debug("diceBot.changeText(string) begin", string) string = @diceBot.changeText(string) debug("diceBot.changeText(string) end", string) string = string.gsub(/([\d]+[dD])([^\d\w]|$)/) {"#{$1}6#{$2}"} debug("parren_killer output", string) return string end </syntaxhighlight> == setCollectRandResult == https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb#L1046-L1052 出目を記録するかどうかを設定するメソッドのようだが、実際には、引数 <code>b</code> に <code>true</code> を設定すると記録スロットを初期化するという動作になっている。<code>false</code> を設定すると記録スロットが <code>nil</code> でクリアされる。 <syntaxhighlight lang="ruby"> def setCollectRandResult(b) if( b ) @randResults = [] else @randResults = nil end end </syntaxhighlight> {{DEFAULTSORT:BCDice くらす}} [[Category:BCDice/内部処理]] db51d156020cef6bc9637268a993d3ad626d895f 134 133 2019-07-01T15:46:55Z Ochaochaocha3 1 /* dice_command */ wikitext text/x-wiki BCDiceの司令塔といえるクラス。ゲームの指定、ダイスロールなどの主要な操作は、このクラスを介して行う。 * v2.02.80.01:https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb __TOC__ == setGameByTitle == https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb#L1778-L1801 指定されたゲーム名のダイスボットを使うように設定する。 # カード機能を初期化する。 # 指定されたゲーム名のダイスボットを設定する。 ## 設定後の処理を行う(<code>diceBot.postSet</code>)。 # ゲームを設定したことを示すメッセージを返す。 <syntaxhighlight lang="ruby"> # 指定したタイトルのゲームを設定する # @param [String] gameTitle ゲームタイトル # @return [String] ゲームを設定したことを示すメッセージ def setGameByTitle(gameTitle) debug('setGameByTitle gameTitle', gameTitle) @cardTrader.initValues loader = DiceBotLoaderList.find(gameTitle) diceBot = if loader loader.loadDiceBot else DiceBotLoader.loadUnknownGame(gameTitle) || DiceBot.new end setDiceBot(diceBot) diceBot.postSet message = "Game設定を#{diceBot.gameName}に設定しました" debug( 'setGameByTitle message', message ) return message end </syntaxhighlight> == setMessage == https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb#L146-L163 ダイスボットに実行させるメッセージを設定する。 # メッセージのパターンに合わせて指定されたメッセージを加工する。 #* <code>Open Dice!</code> や <code>Open Plot!</code>、<code>Set</code> 系は指定されたメッセージそのまま。 #* それ以外の場合、空白の前まで。 # 括弧内前処理を行う。「[[#parren_killer]]」を参照。結果を <code>@messageOriginal</code> に記録する。 # 括弧内前処理の結果に対して、アルファベットを大文字にする。これを次に実行させるメッセージとして <code>@message</code> に記録する。 <syntaxhighlight lang="ruby"> def setMessage(message) # 設定で変化し得るためopen系はここで正規表現を作る openPattern = /\A\s*(?:#{$OPEN_DICE}|#{$OPEN_PLOT})\s*\z/i messageToSet = case message when openPattern, SET_COMMAND_PATTERN message else # 空白が含まれる場合、最初の部分だけを取り出す message.split(/\s/, 2).first end debug("setMessage messageToSet", messageToSet) @messageOriginal = parren_killer(messageToSet) @message = @messageOriginal.upcase debug("@message", @message) end </syntaxhighlight> == parren_killer == https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb#L1550-L1608 括弧内前処理、つまり括弧で囲まれた数式部分を還元して整数に変える処理。 BCDiceのダイス構文は正規文法ではないのに、正規表現だけで処理しようとしているため、無理矢理気味な処理となっている。また、原理上、文法エラーを検出できない場合がある。例えば、 * <code>(2*/2)d6</code> → <code>(2*/2)d6 : (1D6) > 3</code> など。 処理の流れは以下のとおり。 # <code>[<var>n</var>D<var>s</var>]</code> の加算ロールを先に実行する。実際の処理は「[[#rollDiceAddingUp]]」が担当する。 # 範囲構文を数字に変える。「[[#changeRangeTextToNumberText]]」を参照。 # 括弧に入った四則演算(<code>+-*/</code>)を処理する。 # <code><var>n</var>D</code> が残っていたら、<code><var>n</var>D6</code> に変える。 <syntaxhighlight lang="ruby"> def parren_killer(string) debug("parren_killer input", string) while( /^(.*?)\[(\d+[Dd]\d+)\](.*)/ =~ string ) str_before = "" str_after = "" dice_cmd = $2 str_before = $1 if($1) str_after = $3 if($3) rolled, dmy = rollDiceAddingUp(dice_cmd) string = "#{str_before}#{rolled}#{str_after}" end string = changeRangeTextToNumberText(string) while(/^(.*?)(\([\d\/*+-]+?\))(.*)/ =~ string) debug("while string", string) str_a = $3 str_a ||= "" str_b = $1 str_b ||= "" debug("str_b", str_b) par_i = $2 debug("par_i", par_i) par_o = paren_k(par_i) debug("par_o", par_o) if(par_o != 0) if(par_o < 0) if(/(.+?)(\+)$/ =~ str_b) str_b = $1 elsif(/(.+?)(-)$/ =~ str_b) str_b = "#{$1}+" par_o = par_o * -1 end end string = "#{str_b}#{par_o}#{str_a}" else if(/^([DBRUdbru][\d]+)(.*)/ =~ $str_a) str_a = $2 end string = "#{str_b}0#{str_a}" end end debug("diceBot.changeText(string) begin", string) string = @diceBot.changeText(string) debug("diceBot.changeText(string) end", string) string = string.gsub(/([\d]+[dD])([^\d\w]|$)/) {"#{$1}6#{$2}"} debug("parren_killer output", string) return string end </syntaxhighlight> == setCollectRandResult == https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb#L1046-L1052 出目を記録するかどうかを設定するメソッドのようだが、実際には、引数 <code>b</code> に <code>true</code> を設定すると記録スロットを初期化するという動作になっている。<code>false</code> を設定すると記録スロットが <code>nil</code> でクリアされる。 <syntaxhighlight lang="ruby"> def setCollectRandResult(b) if( b ) @randResults = [] else @randResults = nil end end </syntaxhighlight> == dice_command == https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb#L769-L801 ダイスロールを実行する。以下の順で、実行できる処理があればそれを実行し、できなければ次の処理を試すことを繰り返す。 # 指定されたゲームシステムの固有コマンド # D66ロール # 加算ロール <code><var>x</var>D<var>n</var></code> # バラバラロール <code><var>x</var>B<var></var></code> # 個数振り足しロール <code><var>x</var>R<var>n</var></code> # 上方無限ロール <code><var>x</var>U<var>n</var></code> # ランダム選択 <code>choice[<var>A</var>, <var>B</var>, ...]</code> # 独自の表から項目を引く 戻り値は、結果のメッセージと、シークレットロールかどうか。すべての処理に失敗した場合は結果のメッセージが <code>"1"</code> となることに注意。これはPerl時代の名残りと思われる。 <syntaxhighlight lang="ruby"> def dice_command # ダイスコマンドの分岐処理 arg = @message.upcase debug('dice_command arg', arg) output, secret = @diceBot.dice_command(@message, @nick_e) return output, secret if( output != '1' ) output, secret = rollD66(arg) return output, secret unless( output.nil? ) output, secret = checkAddRoll(arg) return output, secret unless( output.nil? ) output, secret = checkBDice(arg) return output, secret unless( output.nil? ) output, secret = checkRnDice(arg) return output, secret unless( output.nil? ) output, secret = checkUpperRoll(arg) return output, secret unless( output.nil? ) output, secret = checkChoiceCommand(arg) return output, secret unless( output.nil? ) output, secret = getTableDataResult(arg) return output, secret unless( output.nil? ) output = '1' secret = false return output, secret end </syntaxhighlight> {{DEFAULTSORT:BCDice くらす}} [[Category:BCDice/内部処理]] ea8d56043aad0068f77b3dfc7a669200effb691c irc.cre.jp系 0 52 137 2019-07-02T14:54:05Z Koi-chan 3 新規作成 wikitext text/x-wiki 「irc.cre.jp系IRCサーバ群」を正式名称とする、[[クリエイターズネットワーク]]が提供する[[IRC]]ネットワークである。旧称「TRPG.NET系」。 2019年現在、日本には他に、独立系のIRCネットワークとしてFriendChat系や[https://www.irc.city.tokyo-3.jp/ 第3新東京市]系などがある。これらのIRCネットワークと比較したときの特徴は以下の通りである。 * 利用可能なニックネームが長い(31文字まで使用可能。プロトコル上は9文字まで、他の多くのネットワークでは25文字まで) * ダイス機能を含む公式のボットが提供されている([[Toybox/Role]]) * チャットには、一部の環境依存文字を含む、多くの文字が使用可能(UTF-8 を採用している) * IRC プロトコルの標準的なサーバ(ircd2.11)を使っていない * [[NickServ]] などの、管理サービスが使用可能 ef461f919e1bbecbdf033130f78531716c574905 141 137 2019-07-05T14:12:51Z Ochaochaocha3 1 /* 概要 */ wikitext text/x-wiki '''irc.cre.jp系'''は、[[クリエイターズネットワーク]]が提供する[[IRC]]ネットワークである。正式名称は「'''irc.cre.jp系IRCサーバ群'''」。旧称「TRPG.NET系」。 == 概要 == 日本の独立系[[IRC]]ネットワーク。様々な話題のためのチャンネルでの会話のほか、設立の経緯からTRPGのオンラインセッションでの利用が多い。 2019年現在、日本の独立系[[IRC]]ネットワークには、他にFriendChat系や[https://www.irc.city.tokyo-3.jp/ 第3新東京市]系などがある。これらのIRCネットワークと比較したときの特徴は以下の通りである。 * 利用可能なニックネームが長い(31文字まで使用可能。プロトコル上は9文字まで、他の多くのネットワークでは25文字まで) * ダイス機能を含む公式のボットが提供されている([[Toybox/Role]]) * チャットには、一部の環境依存文字を含む、多くの文字が使用可能(UTF-8 を採用している) * IRC プロトコルの標準的なサーバ(ircd2.11)を使っていない * [[NickServ]] などの、管理サービスが使用可能 == 関連項目 == * [[クリエイターズネットワーク]] {{DEFAULTSORT:irc.cre.jpけい}} [[Category:IRC]] 18bcfd15ea7d04fa153edef7ab7e0392bd689976 メインページ 0 1 138 50 2019-07-02T14:55:12Z Koi-chan 3 /* ダイスボット */ wikitext text/x-wiki __NOTOC__ == ようこそ {{SITENAME}} へ == オープンソースのTRPGツールの開発や運用に関する情報をまとめるwikiです。ツールの設置の仕方や使われている要素技術など、開発や運用に役立つ情報をまとめていきましょう。 現在、{{SITENAME}}には約 [[Special:Statistics|{{NUMBEROFARTICLES}}]] 本の記事があります。 == 主要なTRPGツール == === Webアプリケーション === * [[どどんとふ]] ** [[ひよんとふ]](ひよこどどんとふクライアント) * [[ユドナリウム]] * [[オンセンルーム]]([[TRPGオンラインセッションSNS]]) * [[ねこ卓]] * [[Quoridorn]] * [[Onset!]] * [[Saider]] * [[Saipage]] === ダイスボット === * [[BCDice]](ボーンズ&カーズ) ** [[BCDice-API]] ** [[discord-bcdicebot]] * [[RGRB]] == 公開サーバー == * [[どどんとふ公式鯖]] * [[どどんとふむせる]] * [[コノスサーバー]] * [[TRPG.NET]] == チャットプラットフォーム == * [[Discord]] * [[IRC]] ** [[irc.cre.jp系]] [[Category:{{SITENAME}}]] {{DEFAULTSORT:めいんへえし}} 561ea799ce35a5e1ed20ce24123b29517a81ad15 139 138 2019-07-02T14:58:21Z Koi-chan 3 /* 主要なTRPGツール */ wikitext text/x-wiki __NOTOC__ == ようこそ {{SITENAME}} へ == オープンソースのTRPGツールの開発や運用に関する情報をまとめるwikiです。ツールの設置の仕方や使われている要素技術など、開発や運用に役立つ情報をまとめていきましょう。 現在、{{SITENAME}}には約 [[Special:Statistics|{{NUMBEROFARTICLES}}]] 本の記事があります。 == 主要なTRPGツール == === Webアプリケーション === * [[どどんとふ]] ** [[ひよんとふ]](ひよこどどんとふクライアント) * [[ユドナリウム]] * [[オンセンルーム]]([[TRPGオンラインセッションSNS]]) * [[ねこ卓]] * [[Quoridorn]] * [[Onset!]] * [[Saider]] * [[Saipage]] === ダイスボット === * [[BCDice]](ボーンズ&カーズ) ** [[BCDice-API]] ** [[discord-bcdicebot]] * [[OD TOOL]] * [[SW2_DLL]] === ジェネレータ === * [[AutoSchenarioWriter]] === オンラインセッション支援ツール === * [[RGRB]] * [[直線距離管理ツール]] == 公開サーバー == * [[どどんとふ公式鯖]] * [[どどんとふむせる]] * [[コノスサーバー]] * [[TRPG.NET]] == チャットプラットフォーム == * [[Discord]] * [[IRC]] ** [[irc.cre.jp系]] [[Category:{{SITENAME}}]] {{DEFAULTSORT:めいんへえし}} 051cd5a967c2337470ccbcd915e8907e2b76818f 140 139 2019-07-02T15:02:54Z Koi-chan 3 [[Special:Contributions/Koi-chan|Koi-chan]] ([[User talk:Koi-chan|トーク]]) による版 139 を取り消し wikitext text/x-wiki __NOTOC__ == ようこそ {{SITENAME}} へ == オープンソースのTRPGツールの開発や運用に関する情報をまとめるwikiです。ツールの設置の仕方や使われている要素技術など、開発や運用に役立つ情報をまとめていきましょう。 現在、{{SITENAME}}には約 [[Special:Statistics|{{NUMBEROFARTICLES}}]] 本の記事があります。 == 主要なTRPGツール == === Webアプリケーション === * [[どどんとふ]] ** [[ひよんとふ]](ひよこどどんとふクライアント) * [[ユドナリウム]] * [[オンセンルーム]]([[TRPGオンラインセッションSNS]]) * [[ねこ卓]] * [[Quoridorn]] * [[Onset!]] * [[Saider]] * [[Saipage]] === ダイスボット === * [[BCDice]](ボーンズ&カーズ) ** [[BCDice-API]] ** [[discord-bcdicebot]] * [[RGRB]] == 公開サーバー == * [[どどんとふ公式鯖]] * [[どどんとふむせる]] * [[コノスサーバー]] * [[TRPG.NET]] == チャットプラットフォーム == * [[Discord]] * [[IRC]] ** [[irc.cre.jp系]] [[Category:{{SITENAME}}]] {{DEFAULTSORT:めいんへえし}} 561ea799ce35a5e1ed20ce24123b29517a81ad15 BCDice/内部処理/AddDiceクラス 0 53 144 2019-07-06T03:25:08Z Ochaochaocha3 1 /* getSlashedDice */ wikitext text/x-wiki 加算ロールの演算処理を担うクラス。 * v2.02.80.01:https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/dice/AddDice.rb __TOC__ == getSlashedDice == https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/dice/AddDice.rb#L290-L311 ダイスロール結果の除算を行う。接尾辞 <code>U</code> や <code>R</code> によって丸め処理の方法を指定することができる。 例: * <code>4D10</code> の結果が <code>30</code> のとき ** 切り捨て:<code>4D10/7</code> → 4.2… → 4 ** 四捨五入:<code>4D10/7R</code> → 4.2… → 4 ** 切り上げ:<code>4D10/7U</code> → 4.2… → 5 * <code>4D10</code> の結果が <code>32</code> のとき ** 切り捨て:<code>4D10/7</code> → 4.5… → 4 ** 四捨五入:<code>4D10/7R</code> → 4.5… → 5 ** 切り上げ:<code>4D10/7U</code> → 4.5… → 5 <syntaxhighlight lang="ruby"> def getSlashedDice(slashMark, dice) return dice unless( /^\/(\d+)(.)?$/i === slashMark ) rate = $1.to_i mark = $2 return dice if( rate == 0 ) value = (1.0 * dice / rate) case mark when "U" dice = value.ceil when "R" dice = value.round else dice = value.floor end return dice end </syntaxhighlight> {{DEFAULTSORT:AddDice くらす}} [[Category:BCDice/内部処理]] 54e38d22e06b4657f7430bad5f086ff41af9b40d MediaWiki:Gadget-exlinks.js 8 54 145 2019-07-28T02:23:25Z Ochaochaocha3 1 「外部リンクを新しいウィンドウ・タブで開く」をバージョン5に更新する javascript text/javascript // ********************************************************************** // ** ***WARNING GLOBAL GADGET FILE*** ** // ** changes to this file affect many users. ** // ** please discuss on the talk page before editing ** // ** ** // ********************************************************************** /** * @source mediawiki.org/wiki/Snippets/Open_external_links_in_new_window * @version 5 */ mw.hook('wikipage.content').add(function($content) { // Second selector is for external links in Parsoid HTML+RDFa output (bug 65243). $content.find('a.external, a[rel="mw:ExtLink"]').each(function () { // Can't use wgServer because it can be protocol relative // Use this.href property instead of this.getAttribute('href') because the property // is converted to a full URL (including protocol) if (this.href.indexOf(location.protocol + '//' + location.hostname) !== 0) { this.target = '_blank'; if ( this.rel.indexOf( 'noopener' ) < 0 ) { this.rel += ' noopener'; // the leading space matters, rel attributes have space-separated tokens } if ( this.rel.indexOf( 'noreferrer' ) < 0 ) { this.rel += ' noreferrer'; // the leading space matters, rel attributes have space-separated tokens } } }); }); b636b061d0b53322a59d9762fe8a17fa411db320 BCDice-API 0 64 156 2020-07-07T06:57:55Z Koi-chan 3 ページの作成:「{{TRPGツール概要 | 開発者 = :[https://twitter.com/ysakasin 酒田 シンジ] | GitHubリポジトリ = [https://github.com/bcdice/bcdice-api bcdice/bcdice-api]…」 wikitext text/x-wiki {{TRPGツール概要 | 開発者 = :[https://twitter.com/ysakasin 酒田 シンジ] | GitHubリポジトリ = [https://github.com/bcdice/bcdice-api bcdice/bcdice-api] | 使用技術 = [[Ruby]] }} '''BCDice-API'''は、ダイスボットWebAPIのひとつ。 [https://twitter.com/ysakasin 酒田 シンジ]を中心として開発が進められている。 == 概要 == [[BCDice]]を振るためのWebAPI。[[Saipage]]をはじめとした多くのTRPGツールに使用されている。 そのままの状態のBCDiceはライブラリとして利用するには不便であるため、他のプログラムからダイスロールを簡単に得るために開発された。BCDice-APIは現在[[どどんとふ公式鯖]]に設置されており、TRPGツールの開発において気軽にBCDiceを利用することができる。 == 関連項目 == [[Category:ダイスボット]] [[Category:BCDice|*BCDice]] ddbf9fda5089ee16eaa30c8181f4fe0dbcb66ca9 158 156 2020-07-07T07:07:24Z Koi-chan 3 wikitext text/x-wiki {{TRPGツール概要 | 開発者 = :[https://twitter.com/ysakasin 酒田 シンジ] | GitHubリポジトリ = [https://github.com/bcdice/bcdice-api bcdice/bcdice-api] | 使用技術 = [[Ruby]] }} '''BCDice-API'''は、ダイスボットWebAPIのひとつ。 [https://twitter.com/ysakasin 酒田 シンジ]を中心として開発が進められている。 == 概要 == [[BCDice]]を振るためのWebAPI。[[Saipage]]をはじめとした多くのTRPGツールに使用されている。 そのままの状態のBCDiceはライブラリとして利用するには不便であるため、他のプログラムからダイスロールを簡単に得るために開発された。BCDice-APIは現在[[どどんとふ公式鯖]]に設置されており、TRPGツールの開発において気軽にBCDiceを利用することができる。 == 設置されている主なサーバ == 公開サーバは、[https://github.com/bcdice/bcdice-api-servers GitHub上のリポジトリ]で一覧できる。 また、[https://api-status.bcdice.org BCDice-API バージョン一覧]では、公開サーバで利用可能なBCDice-API及びBCDice本体のバージョンが分かる。 == 関連項目 == [[Category:ダイスボット]] [[Category:BCDice|*BCDice]] 6312a04874e0762e3b5f78f839a329b1bbdb112d 159 158 2020-07-07T07:07:45Z Koi-chan 3 wikitext text/x-wiki {{TRPGツール概要 | 開発者 = [https://twitter.com/ysakasin 酒田 シンジ] | GitHubリポジトリ = [https://github.com/bcdice/bcdice-api bcdice/bcdice-api] | 使用技術 = [[Ruby]] }} '''BCDice-API'''は、ダイスボットWebAPIのひとつ。 [https://twitter.com/ysakasin 酒田 シンジ]を中心として開発が進められている。 == 概要 == [[BCDice]]を振るためのWebAPI。[[Saipage]]をはじめとした多くのTRPGツールに使用されている。 そのままの状態のBCDiceはライブラリとして利用するには不便であるため、他のプログラムからダイスロールを簡単に得るために開発された。BCDice-APIは現在[[どどんとふ公式鯖]]に設置されており、TRPGツールの開発において気軽にBCDiceを利用することができる。 == 設置されている主なサーバ == 公開サーバは、[https://github.com/bcdice/bcdice-api-servers GitHub上のリポジトリ]で一覧できる。 また、[https://api-status.bcdice.org BCDice-API バージョン一覧]では、公開サーバで利用可能なBCDice-API及びBCDice本体のバージョンが分かる。 == 関連項目 == [[Category:ダイスボット]] [[Category:BCDice|*BCDice]] b2e099b17beac151e7614d51abe01f281358b973 BCDice/内部処理 0 50 161 143 2020-07-08T09:12:21Z ! あべ 8 wikitext text/x-wiki == クラス == * [[/BCDiceクラス]] * [[/BCDiceMakerクラス]] * [[/AddDiceクラス]]:加算ロールの演算 {{DEFAULTSORT:ないふしょり}} [[Category:BCDice]] fd19d3420e50d5219a142845e6b98ea235d97d34 163 161 2020-07-10T17:13:28Z Ochaochaocha3 1 [[Special:Contributions/! あべ|! あべ]] ([[User talk:! あべ|トーク]]) による編集を [[User:Ochaochaocha3|Ochaochaocha3]] による直前の版へ差し戻しました wikitext text/x-wiki 本ページ以下では、[[BCDice]]でどのような処理が行われているかをまとめる。 == クラス == * [[/BCDiceクラス]] * [[/BCDiceMakerクラス]] * [[/AddDiceクラス]]:加算ロールの演算 {{DEFAULTSORT:ないふしょり}} [[Category:BCDice]] 299241350e428b801cd0384c310529433197084b 182 163 2020-08-24T21:34:27Z 0ヴ 9 wikitext text/x-wiki 本ページ以下では、[[BCDice]]でどのような処理が行われているかをまとめる == クラス == * [[/BCDiceクラス]] * [[/BCDiceMakerクラス]] * [[/AddDiceクラス]]:加算ロールの演算 {{DEFAULTSORT:ないふしょり}} [[Category:BCDice]] f6edd68ebb52f9e09cb3008dbc8244a92e72af01 203 182 2020-08-26T22:41:58Z 2400:4153:84E0:AC00:B5C3:DB95:924F:6C8E 0 [[Special:Contributions/0ヴ|0ヴ]] ([[User talk:0ヴ|トーク]]) による版 182 を取り消し wikitext text/x-wiki 本ページ以下では、[[BCDice]]でどのような処理が行われているかをまとめる。 == クラス == * [[/BCDiceクラス]] * [[/BCDiceMakerクラス]] * [[/AddDiceクラス]]:加算ロールの演算 {{DEFAULTSORT:ないふしょり}} [[Category:BCDice]] 299241350e428b801cd0384c310529433197084b メインページ 0 1 164 140 2020-07-19T00:31:57Z 153.189.99.60 0 [[Special:Contributions/Koi-chan|Koi-chan]] ([[User talk:Koi-chan|トーク]]) による版 140 を取り消し wikitext text/x-wiki __NOTOC__ == ようこそ {{SITENAME}} へ == オープンソースのTRPGツールの開発や運用に関する情報をまとめるwikiです。ツールの設置の仕方や使われている要素技術など、開発や運用に役立つ情報をまとめていきましょう。 現在、{{SITENAME}}には約 [[Special:Statistics|{{NUMBEROFARTICLES}}]] 本の記事があります。 == 主要なTRPGツール == === Webアプリケーション === * [[どどんとふ]] ** [[ひよんとふ]](ひよこどどんとふクライアント) * [[ユドナリウム]] * [[オンセンルーム]]([[TRPGオンラインセッションSNS]]) * [[ねこ卓]] * [[Quoridorn]] * [[Onset!]] * [[Saider]] * [[Saipage]] === ダイスボット === * [[BCDice]](ボーンズ&カーズ) ** [[BCDice-API]] ** [[discord-bcdicebot]] * [[OD TOOL]] * [[SW2_DLL]] === ジェネレータ === * [[AutoSchenarioWriter]] === オンラインセッション支援ツール === * [[RGRB]] * [[直線距離管理ツール]] == 公開サーバー == * [[どどんとふ公式鯖]] * [[どどんとふむせる]] * [[コノスサーバー]] * [[TRPG.NET]] == チャットプラットフォーム == * [[Discord]] * [[IRC]] ** [[irc.cre.jp系]] [[Category:{{SITENAME}}]] {{DEFAULTSORT:めいんへえし}} 051cd5a967c2337470ccbcd915e8907e2b76818f 165 164 2020-08-06T20:42:53Z 122.21.75.43 0 [[Special:Contributions/153.189.99.60|153.189.99.60]] ([[User talk:153.189.99.60|トーク]]) による版 164 を取り消し wikitext text/x-wiki __NOTOC__ == ようこそ {{SITENAME}} へ == オープンソースのTRPGツールの開発や運用に関する情報をまとめるwikiです。ツールの設置の仕方や使われている要素技術など、開発や運用に役立つ情報をまとめていきましょう。 現在、{{SITENAME}}には約 [[Special:Statistics|{{NUMBEROFARTICLES}}]] 本の記事があります。 == 主要なTRPGツール == === Webアプリケーション === * [[どどんとふ]] ** [[ひよんとふ]](ひよこどどんとふクライアント) * [[ユドナリウム]] * [[オンセンルーム]]([[TRPGオンラインセッションSNS]]) * [[ねこ卓]] * [[Quoridorn]] * [[Onset!]] * [[Saider]] * [[Saipage]] === ダイスボット === * [[BCDice]](ボーンズ&カーズ) ** [[BCDice-API]] ** [[discord-bcdicebot]] * [[RGRB]] == 公開サーバー == * [[どどんとふ公式鯖]] * [[どどんとふむせる]] * [[コノスサーバー]] * [[TRPG.NET]] == チャットプラットフォーム == * [[Discord]] * [[IRC]] ** [[irc.cre.jp系]] [[Category:{{SITENAME}}]] {{DEFAULTSORT:めいんへえし}} 561ea799ce35a5e1ed20ce24123b29517a81ad15 171 165 2020-08-24T19:42:18Z 0ヴ 9 wikitext text/x-wiki __NOTOC_ == ようこそ {{SITENAME}} へ == オープンソースのTRPGツールの開発や運用に関する情報をまとめるwikiです。ツールの設置の仕方や使われている要素技術など、開発や運用に役立つ情報をまとめていきましょう。 現在、{{SITENAME}}には約 [[Special:Statistics|{{NUMBEROFARTICLES}}]] 本の記事があります。 == 主要なTRPGツール == === Webアプリケーション === * [[どどんとふ]] ** [[ひよんとふ]](ひよこどどんとふクライアント) * [[ユドナリウム]] * [[オンセンルーム]]([[TRPGオンラインセッションSNS]]) * [[ねこ卓]] * [[Quoridorn]] * [[Onset!]] * [[Saider]] * [[Saipage]] === ダイスボット === * [[BCDice]](ボーンズ&カーズ) ** [[BCDice-API]] ** [[discord-bcdicebot]] * [[RGRB]] == 公開サーバー == * [[どどんとふ公式鯖]] * [[どどんとふむせる]] * [[コノスサーバー]] * [[TRPG.NET]] == チャットプラットフォーム == * [[Discord]] * [[IRC]] ** [[irc.cre.jp系]] [[Category:{{SITENAME}}]] {{DEFAULTSORT:めいんへえし}} 9a46f70ce3e50eb19bb20b141721612cf846e4b5 172 171 2020-08-24T19:45:46Z 0ヴ 9 /* ようこそ TRPGツール開発・運用Wiki へ */ wikitext text/x-wiki __NOTOC_ == ようこそ {{SITENAME}} へ == オープンソースのTRPGツールの開発や運用に関する情報をまとめるwikiです。ツールの設置の仕方や使われている要素技術など、開発や運用に役立つ情報をまとめていきましょう。 現在、{{SITENAME}}には約 [[Special:Statistics|{{NUMBEROFARTICLES}}]] 本の記事があります == 主要なTRPGツール == === Webアプリケーション === * [[どどんとふ]] ** [[ひよんとふ]](ひよこどどんとふクライアント) * [[ユドナリウム]] * [[オンセンルーム]]([[TRPGオンラインセッションSNS]]) * [[ねこ卓]] * [[Quoridorn]] * [[Onset!]] * [[Saider]] * [[Saipage]] === ダイスボット === * [[BCDice]](ボーンズ&カーズ) ** [[BCDice-API]] ** [[discord-bcdicebot]] * [[RGRB]] == 公開サーバー == * [[どどんとふ公式鯖]] * [[どどんとふむせる]] * [[コノスサーバー]] * [[TRPG.NET]] == チャットプラットフォーム == * [[Discord]] * [[IRC]] ** [[irc.cre.jp系]] [[Category:{{SITENAME}}]] {{DEFAULTSORT:めいんへえし}} ef3a24d947228be8dcb0282a2c5f7f486ffb87b7 187 172 2020-08-24T22:41:06Z 118.10.82.175 0 [[Special:Contributions/0ヴ|0ヴ]] ([[User talk:0ヴ|トーク]]) による版 172 を取り消し wikitext text/x-wiki __NOTOC_ == ようこそ {{SITENAME}} へ == オープンソースのTRPGツールの開発や運用に関する情報をまとめるwikiです。ツールの設置の仕方や使われている要素技術など、開発や運用に役立つ情報をまとめていきましょう。 現在、{{SITENAME}}には約 [[Special:Statistics|{{NUMBEROFARTICLES}}]] 本の記事があります。 == 主要なTRPGツール == === Webアプリケーション === * [[どどんとふ]] ** [[ひよんとふ]](ひよこどどんとふクライアント) * [[ユドナリウム]] * [[オンセンルーム]]([[TRPGオンラインセッションSNS]]) * [[ねこ卓]] * [[Quoridorn]] * [[Onset!]] * [[Saider]] * [[Saipage]] === ダイスボット === * [[BCDice]](ボーンズ&カーズ) ** [[BCDice-API]] ** [[discord-bcdicebot]] * [[RGRB]] == 公開サーバー == * [[どどんとふ公式鯖]] * [[どどんとふむせる]] * [[コノスサーバー]] * [[TRPG.NET]] == チャットプラットフォーム == * [[Discord]] * [[IRC]] ** [[irc.cre.jp系]] [[Category:{{SITENAME}}]] {{DEFAULTSORT:めいんへえし}} 9a46f70ce3e50eb19bb20b141721612cf846e4b5 192 187 2020-08-26T03:53:55Z Koi-chan 3 wikitext text/x-wiki __NOTOC__ == ようこそ {{SITENAME}} へ == オープンソースのTRPGツールの開発や運用に関する情報をまとめるwikiです。ツールの設置の仕方や使われている要素技術など、開発や運用に役立つ情報をまとめていきましょう。 現在、{{SITENAME}}には約 [[Special:Statistics|{{NUMBEROFARTICLES}}]] 本の記事があります。 == 主要なTRPGツール == === Webアプリケーション === * [[どどんとふ]] ** [[ひよんとふ]](ひよこどどんとふクライアント) * [[ユドナリウム]] * [[オンセンルーム]]([[TRPGオンラインセッションSNS]]) * [[ねこ卓]] * [[Quoridorn]] * [[Onset!]] * [[Saider]] * [[Saipage]] === ダイスボット === * [[BCDice]](ボーンズ&カーズ) ** [[BCDice-API]] ** [[discord-bcdicebot]] * [[RGRB]] == 公開サーバー == * [[どどんとふ公式鯖]] * [[どどんとふむせる]] * [[コノスサーバー]] * [[TRPG.NET]] == チャットプラットフォーム == * [[Discord]] * [[IRC]] ** [[irc.cre.jp系]] [[Category:{{SITENAME}}]] {{DEFAULTSORT:めいんへえし}} f1b2a2c4f1521327559f3537176154c0ea066962 194 192 2020-08-26T20:55:47Z 0ヴ 9 /* ようこそ TRPGツール開発・運用Wiki へ */ wikitext text/x-wiki __NOTOC__ == ようこそ {{SITENAME}} へ == オープンソースのTRPGツールの開発や運用に関する情報をまとめるwikiです。ツールの設置の仕方や使われている要素技術など、開発や運用に役立つ情報をまとめていきましょう。 現在、{{SITENAME}}には約 [[Special:Statistics|{{NUMBEROFARTICLES}}]] 本の記事があります == 主要なTRPGツール == === Webアプリケーション === * [[どどんとふ]] ** [[ひよんとふ]](ひよこどどんとふクライアント) * [[ユドナリウム]] * [[オンセンルーム]]([[TRPGオンラインセッションSNS]]) * [[ねこ卓]] * [[Quoridorn]] * [[Onset!]] * [[Saider]] * [[Saipage]] === ダイスボット === * [[BCDice]](ボーンズ&カーズ) ** [[BCDice-API]] ** [[discord-bcdicebot]] * [[RGRB]] == 公開サーバー == * [[どどんとふ公式鯖]] * [[どどんとふむせる]] * [[コノスサーバー]] * [[TRPG.NET]] == チャットプラットフォーム == * [[Discord]] * [[IRC]] ** [[irc.cre.jp系]] [[Category:{{SITENAME}}]] {{DEFAULTSORT:めいんへえし}} 1903fe345a6844373f024ef80dfdc5702712e4d6 196 194 2020-08-26T22:08:37Z 2400:4153:84E0:AC00:B5C3:DB95:924F:6C8E 0 [[Special:Contributions/0ヴ|0ヴ]] ([[User talk:0ヴ|トーク]]) による版 194 を取り消し wikitext text/x-wiki __NOTOC__ == ようこそ {{SITENAME}} へ == オープンソースのTRPGツールの開発や運用に関する情報をまとめるwikiです。ツールの設置の仕方や使われている要素技術など、開発や運用に役立つ情報をまとめていきましょう。 現在、{{SITENAME}}には約 [[Special:Statistics|{{NUMBEROFARTICLES}}]] 本の記事があります。 == 主要なTRPGツール == === Webアプリケーション === * [[どどんとふ]] ** [[ひよんとふ]](ひよこどどんとふクライアント) * [[ユドナリウム]] * [[オンセンルーム]]([[TRPGオンラインセッションSNS]]) * [[ねこ卓]] * [[Quoridorn]] * [[Onset!]] * [[Saider]] * [[Saipage]] === ダイスボット === * [[BCDice]](ボーンズ&カーズ) ** [[BCDice-API]] ** [[discord-bcdicebot]] * [[RGRB]] == 公開サーバー == * [[どどんとふ公式鯖]] * [[どどんとふむせる]] * [[コノスサーバー]] * [[TRPG.NET]] == チャットプラットフォーム == * [[Discord]] * [[IRC]] ** [[irc.cre.jp系]] [[Category:{{SITENAME}}]] {{DEFAULTSORT:めいんへえし}} f1b2a2c4f1521327559f3537176154c0ea066962 208 196 2020-08-27T08:57:31Z 0ヴ 9 /* 主要なTRPGツール */ wikitext text/x-wiki __NOTOC__ == ようこそ {{SITENAME}} へ == オープンソースのTRPGツールの開発や運用に関する情報をまとめるwikiです。ツールの設置の仕方や使われている要素技術など、開発や運用に役立つ情報をまとめていきましょう。 現在、{{SITENAME}}には約 [[Special:Statistics|{{NUMBEROFARTICLES}}]] 本の記事があります。 == 主要なTRPGツール == === Webアプリケーション === * [[どどんとふ]] ** [[ひよんとふ]](ひよこどどんとふクライアント) * [[ユドナリウム]] * [[オンセンルーム]]([[TRPGオンラインセッションSNS]]) * [[ねこ卓]] * [[Quoridorn]] * [[Onset!]] * [[Saider]] * [[Saipage]] === ダイスボット === * [[BCDice]](ボーンズ&カーズ) ** [[BCDice-API]] ** [[discord-bcdicebot]] * [[RGRB] == 公開サーバー == * [[どどんとふ公式鯖]] * [[どどんとふむせる]] * [[コノスサーバー]] * [[TRPG.NET]] == チャットプラットフォーム == * [[Discord]] * [[IRC]] ** [[irc.cre.jp系]] [[Category:{{SITENAME}}]] {{DEFAULTSORT:めいんへえし}} adc5c1d58828ae63c295c28c0dc7e11a350f43c1 210 208 2020-08-27T20:49:02Z 0ヴ 9 /* ようこそ TRPGツール開発・運用Wiki へ */ wikitext text/x-wiki __NOTOC__ == ようこそ {{SITENAME}} へ == オープンソースのTRPGツールの開発や運用に関する情報をまとめるwikiです。ツールの設置の仕方や使われている要素技術など、開発や運用に役立つ情報をまとめていきましょう。 現在、{{SITENAME}}には約 [[Special:Statistics|{{NUMBEROFARTICLES}}]] 本の記事があります == 主要なTRPGツール == === Webアプリケーション === * [[どどんとふ]] ** [[ひよんとふ]](ひよこどどんとふクライアント) * [[ユドナリウム]] * [[オンセンルーム]]([[TRPGオンラインセッションSNS]]) * [[ねこ卓]] * [[Quoridorn]] * [[Onset!]] * [[Saider]] * [[Saipage]] === ダイスボット === * [[BCDice]](ボーンズ&カーズ) ** [[BCDice-API]] ** [[discord-bcdicebot]] * [[RGRB] == 公開サーバー == * [[どどんとふ公式鯖]] * [[どどんとふむせる]] * [[コノスサーバー]] * [[TRPG.NET]] == チャットプラットフォーム == * [[Discord]] * [[IRC]] ** [[irc.cre.jp系]] [[Category:{{SITENAME}}]] {{DEFAULTSORT:めいんへえし}} 0c1f5b9fe931ec636374b66da8d758d6f209ba94 212 210 2020-08-28T09:27:39Z 0ヴ 9 /* ようこそ TRPGツール開発・運用Wiki へ */ wikitext text/x-wiki __NOTOC__ == ようこそ {{SITENAME}} へ == オープンソースのTRPGツールの開発や運用に関する情報をまとめるwikiです。ツールの設置の仕方や使われている要素技術など、開発や運用に役立つ情報をまとめていきましょう。 現在、{{SITENAME}}には約 [[Special:Statistics|{{NUMBEROFARTICLES}}]] 本の記事がありま == 主要なTRPGツール == === Webアプリケーション === * [[どどんとふ]] ** [[ひよんとふ]](ひよこどどんとふクライアント) * [[ユドナリウム]] * [[オンセンルーム]]([[TRPGオンラインセッションSNS]]) * [[ねこ卓]] * [[Quoridorn]] * [[Onset!]] * [[Saider]] * [[Saipage]] === ダイスボット === * [[BCDice]](ボーンズ&カーズ) ** [[BCDice-API]] ** [[discord-bcdicebot]] * [[RGRB] == 公開サーバー == * [[どどんとふ公式鯖]] * [[どどんとふむせる]] * [[コノスサーバー]] * [[TRPG.NET]] == チャットプラットフォーム == * [[Discord]] * [[IRC]] ** [[irc.cre.jp系]] [[Category:{{SITENAME}}]] {{DEFAULTSORT:めいんへえし}} 9e5156114d1db15699e2ca588f7b64730c3255f5 214 212 2020-08-28T10:03:34Z 0ヴ 9 /* 主要なTRPGツール */ wikitext text/x-wiki __NOTOC__ == ようこそ {{SITENAME}} へ == オープンソースのTRPGツールの開発や運用に関する情報をまとめるwikiです。ツールの設置の仕方や使われている要素技術など、開発や運用に役立つ情報をまとめていきましょう。 現在、{{SITENAME}}には約 [[Special:Statistics|{{NUMBEROFARTICLES}}]] 本の記事がありま == 主要なTRPGツール == === Webアプリケーション === * [[どどんとふ]] ** [[ひよんとふ]](ひよこどどんとふクライアント) * [[ユドナリウム]] * [[オンセンルーム]]([[TRPGオンラインセッションSNS]]) * [[ねこ卓]] * [[Quoridorn]] * [[Onset!]] * [[Saider]] * [[Saipage]] === ダイスボット === * [[BCDice]](ボーンズ&カーズ) ** [[BCDice-API]] ** [[discord-bcdicebot]] * [[RGRB == 公開サーバー == * [[どどんとふ公式鯖]] * [[どどんとふむせる]] * [[コノスサーバー]] * [[TRPG.NET]] == チャットプラットフォーム == * [[Discord]] * [[IRC]] ** [[irc.cre.jp系]] [[Category:{{SITENAME}}]] {{DEFAULTSORT:めいんへえし}} 3bdb30b6f4bcfcd557f3a35ebdf0419dd5b97e73 216 214 2020-08-28T20:08:38Z 0ヴ 9 /* 主要なTRPGツール */ wikitext text/x-wiki __NOTOC__ == ようこそ {{SITENAME}} へ == オープンソースのTRPGツールの開発や運用に関する情報をまとめるwikiです。ツールの設置の仕方や使われている要素技術など、開発や運用に役立つ情報をまとめていきましょう。 現在、{{SITENAME}}には約 [[Special:Statistics|{{NUMBEROFARTICLES}}]] 本の記事がありま == 主要なTRPGツール == === Webアプリケーション === * [[どどんとふ]] ** [[ひよんとふ]](ひよこどどんとふクライアント) * [[ユドナリウム]] * [[オンセンルーム]]([[TRPGオンラインセッションSNS]]) * [[ねこ卓]] * [[Quoridorn]] * [[Onset!]] * [[Saider]] * [[Saipage]] === ダイスボット === * [[BCDice]](ボーンズ&カーズ) ** [[BCDice-API]] ** [[discord-bcdicebot]] * [[RGR == 公開サーバー == * [[どどんとふ公式鯖]] * [[どどんとふむせる]] * [[コノスサーバー]] * [[TRPG.NET]] == チャットプラットフォーム == * [[Discord]] * [[IRC]] ** [[irc.cre.jp系]] [[Category:{{SITENAME}}]] {{DEFAULTSORT:めいんへえし}} 82b7e6d35c096067f310e4cb6038e559f6c0dbec 217 216 2020-08-28T22:24:03Z 118.10.82.175 0 [[Special:Contributions/0ヴ|0ヴ]] ([[User talk:0ヴ|トーク]]) による版 216 を取り消し wikitext text/x-wiki __NOTOC__ == ようこそ {{SITENAME}} へ == オープンソースのTRPGツールの開発や運用に関する情報をまとめるwikiです。ツールの設置の仕方や使われている要素技術など、開発や運用に役立つ情報をまとめていきましょう。 現在、{{SITENAME}}には約 [[Special:Statistics|{{NUMBEROFARTICLES}}]] 本の記事がありま == 主要なTRPGツール == === Webアプリケーション === * [[どどんとふ]] ** [[ひよんとふ]](ひよこどどんとふクライアント) * [[ユドナリウム]] * [[オンセンルーム]]([[TRPGオンラインセッションSNS]]) * [[ねこ卓]] * [[Quoridorn]] * [[Onset!]] * [[Saider]] * [[Saipage]] === ダイスボット === * [[BCDice]](ボーンズ&カーズ) ** [[BCDice-API]] ** [[discord-bcdicebot]] * [[RGRB == 公開サーバー == * [[どどんとふ公式鯖]] * [[どどんとふむせる]] * [[コノスサーバー]] * [[TRPG.NET]] == チャットプラットフォーム == * [[Discord]] * [[IRC]] ** [[irc.cre.jp系]] [[Category:{{SITENAME}}]] {{DEFAULTSORT:めいんへえし}} 3bdb30b6f4bcfcd557f3a35ebdf0419dd5b97e73 218 217 2020-08-29T07:21:02Z 0ヴ 9 /* 主要なTRPGツール */ wikitext text/x-wiki __NOTOC__ == ようこそ {{SITENAME}} へ == オープンソースのTRPGツールの開発や運用に関する情報をまとめるwikiです。ツールの設置の仕方や使われている要素技術など、開発や運用に役立つ情報をまとめていきましょう。 現在、{{SITENAME}}には約 [[Special:Statistics|{{NUMBEROFARTICLES}}]] 本の記事がありま == 主要なTRPGツール == === Webアプリケーション === * [[どどんとふ]] ** [[ひよんとふ]](ひよこどどんとふクライアント) * [[ユドナリウム]] * [[オンセンルーム]]([[TRPGオンラインセッションSNS]]) * [[ねこ卓]] * [[Quoridorn]] * [[Onset!]] * [[Saider]] * [[Saipage]] === ダイスボット === * [[BCDice]](ボーンズ&カーズ) ** [[BCDice-API]] ** [[discord-bcdicebot]] * [[RGR == 公開サーバー == * [[どどんとふ公式鯖]] * [[どどんとふむせる]] * [[コノスサーバー]] * [[TRPG.NET]] == チャットプラットフォーム == * [[Discord]] * [[IRC]] ** [[irc.cre.jp系]] [[Category:{{SITENAME}}]] {{DEFAULTSORT:めいんへえし}} 82b7e6d35c096067f310e4cb6038e559f6c0dbec どどんとふ 0 10 166 102 2020-08-06T20:47:23Z 122.21.75.43 0 [[Special:Contributions/Ochaochaocha3|Ochaochaocha3]] ([[User talk:Ochaochaocha3|トーク]]) による版 102 を取り消し wikitext text/x-wiki {{TRPGツール概要 | image = ファイル:dodontof-screenshot.png | キャプション = どどんとふのスクリーンショット | 開発者 = [https://twitter.com/torgtaitai たいたい竹流] | 公式サイト = [http://www.dodontof.com/ どどんとふ@えくすとり~む] | 公式マニュアル = [http://www.melonbooks.com/index.php?main_page=product_info&products_id=IT0000197863 どどんとふで始める初めてのオンラインセッション2017年夏の号!] | GitHubリポジトリ = [https://github.com/torgtaitai/DodontoF torgtaitai/DodontoF] | 使用技術 = [[Flash]]、[[Ruby]] }} '''どどんとふ'''は、[https://twitter.com/torgtaitai たいたい竹流氏]によって開発されているオンラインセッションツール。 == 概要 == オンラインセッションに必要な多くの機能を備えた、総合オンラインセッションツール。部屋の作成、チャット、ダイスボット、キャラクター管理、マップ管理、イニシアティブ表といった基本的な機能に加えて、以下のような豊富な機能を搭載している。 * 秘話チャット * シークレットダイス * ダイスシンボル * 共有メモ * カード * 資源管理 * 範囲 * 魔法タイマー * チット設置 * マップ手書き * 画像のアップロード * Webカメラ撮影 * 立ち絵 * ノベルゲーム風表示 * カットイン * 読み上げ * リプレイ録画 * 多言語対応 === ダイスボット === ダイスボットとして[[BCDice]](ボーンズ&カーズ)を使用している。現在のBCDiceは、どどんとふ環境で動作することを前提として開発、テストされている。様々なゲームシステムのダイスロールおよび表引きに加え、独自の表の追加、カード機能などBCDiceの機能をフル活用しているのは、どどんとふならではである。 == Flashの廃止に伴う影響 == どどんとふのクライアントプログラム(プレイヤーが操作する画面のプログラム)は、[[Flash]]を使用して作られている。Flashは2020年に廃止されることが決定しており、2021年以降、通常はブラウザからクライアントプログラムを動作させることができなくなる。そのため、[[どどんとふ公式鯖]]<ref>[https://twitter.com/DoDontoF_Srv/status/1112201807239901184 どどんとふ公式鯖とねこ卓公式鯖と氷丼公式鯖中の人さんのツイート: "2020年12月にどどんとふ公式鯖終了がかなり濃厚です。HTML5版を残すかは開発体制状況次第です。 Quoridornやねこ卓その他ツールは継続予定ですが、サーバー負荷は激減するけど収益も激減するのは確実なので、そこら辺をどうするかも課題です。無罪になったのにCoinhive無くなっちゃうしなあ。"]</ref>や[[どどんとふむせる]]<ref>[http://museru.blog.jp/archives/1066846255.html どどんとふ「むせる」の終了時期について : むせるいんふぉめーしょん]</ref>では、管理者が2020年にどどんとふの提供を終了することを宣言している。 なお、[[Ruby]]で書かれているどどんとふのサーバープログラムは、Flash廃止の影響を受けず、2021年以降も動作する。そのため、クライアントプログラムのみ[[HTML5]]で書き直す試みが行われている(kitt氏の[[HTML5版どどんとふ]])。HTML5版のクライアントが十分に動作するようになれば、2021年以降もどどんとふを使ってオンラインセッションを楽しむことができる可能性はある。 == 設置 == === 小規模サーバー === 以下の説明は公式マニュアル<ref>[http://www.melonbooks.com/index.php?main_page=product_info&products_id=IT0000197863 どどんとふで始める初めてのオンラインセッション2017年夏の号!]</ref>を基にしている。 少人数で使用する場合は、[[Ruby]](1.8.7以上)が使えるレンタルサーバーにファイルを置き、パーミッションの設定をするだけでよい。マニュアルでは、さくらインターネットのレンタルサーバー([https://www.sakura.ne.jp/ さくらのレンタルサーバ])が推奨されている。 まず、公式サイトの[http://www.dodontof.com/index.php?option=com_content&view=article&id=246&Itemid=126 ダウンロードページ]から最新版または安定版のzipファイルをダウンロードし、展開する。さくらのレンタルサーバでアカウント名が「trpg_net」の場合、展開したファイルを以下のように配置し、パーミッションを設定する。 <pre> home +- trpg_net +- www | +- DodontoF (705) | | +- DodontoFServer.rb (705) | | +- log.txt (600) | | +- log.txt.0 (600) | | +- saveDataTempSpace (705) | | +- fileUploadSpace (705) | | +- replayDataUploadSpace (705) | +- imageUploadSpace (705) | +- smallImages (705) +- saveData (705) </pre> ファイルの配置およびパーミッション設定が完了したら、ブラウザから <code>DodontoF/DodontoFServer.rb</code> を開く。上記の例の場合、URLは <pre>http://trpg_net.sakura.ne.jp/DodontoF/DodontoFServer.rb</pre> となる。ファイルの配置およびパーミッション設定が正しくできていれば、以下のように表示される。 <syntaxhighlight lang="json"> ["「どどんとふ」の動作環境は正常に起動しています。"] </syntaxhighlight> 上記のメッセージが表示されたら、<code>DodontoF/DodontoF.swf</code> を開く。上記の例の場合、URLは <pre>http://trpg_net.sakura.ne.jp/DodontoF/DodontoF.swf</pre> となる。 === 大規模サーバー === レンタルサーバーを使う場合、快適に使用できる人数は10人程度までであり、それ以上の人数では負荷が重くなる。大規模なサーバーでは、以下のような構成とする例が多い。 * より高性能なサーバーやVPSを使う。 ** SSDを使う。 ** メモリに余裕があれば、RAMディスクを使う。 ** 必要に応じて、TCP/IPに関するLinuxカーネルのチューニングを行う。 * Webサーバーとしてnginxを使う。 * 最新のRubyを使う。 * FastCGIを使う。 ** spawn-fcgiなどでサーバープログラムを起動する。 ** Gem「fcgi」を使う。 * Gem「msgpack」を使う。 * 擬似cometモードを使わない。 設置の手順を解説している記事として、以下のものがある。 * [http://cre.jp/techblog/2016/01/27/dodontof-centos7-nginx-spawn/ クリエイターズネットワーク技術部ブログ » CentOS7+nginx+spawn-fcgi でどどんとふを動かす] ** [[TRPG.NET]]へのどどんとふの設置時の作業を基にしている。 * 大ちゃんのいろいろ雑記 - どどんとふをdebian+nginxで動かすやり方(nginxセットアップ編)@公式鯖3rdシリーズ ** [[どどんとふ公式鯖]]へのどどんとふ設置作業の記録。ハードウェアの性能を満たすのは難しいが、各要素は参考になる。 *# [https://www.taruki.com/wp/?p=6099 OS編] *# [https://www.taruki.com/wp/?p=6123 nginxセットアップ編] *# [https://www.taruki.com/wp/?p=6133 fcgi編] *# [https://www.taruki.com/wp/?p=6160 どどんとふ本体編] *# [https://www.taruki.com/wp/?p=6162 運用ツール編(最低限)] *# [https://www.taruki.com/wp/?p=6165 運用ツール編(その他)] *# [https://www.taruki.com/wp/?p=6182 運用ツール編(負荷グラフ)] == 脚注 == <references /> [[Category:TRPGツール]] {{DEFAULTSORT:ととんとふ}} 227879fa78c6ff5ea255782e26a455d7ecea9dbc 167 166 2020-08-06T22:03:01Z Ochaochaocha3 1 [[Special:Contributions/122.21.75.43|122.21.75.43]] ([[User talk:122.21.75.43|トーク]]) による版 166 を取り消し wikitext text/x-wiki {{TRPGツール概要 | image = ファイル:dodontof-screenshot.png | キャプション = どどんとふのスクリーンショット | 開発者 = [https://twitter.com/torgtaitai たいたい竹流] | 公式サイト = [http://www.dodontof.com/ どどんとふ@えくすとり~む] | 公式マニュアル = [http://www.melonbooks.com/index.php?main_page=product_info&products_id=IT0000197863 どどんとふで始める初めてのオンラインセッション2017年夏の号!] | GitHubリポジトリ = [https://github.com/torgtaitai/DodontoF torgtaitai/DodontoF] | 使用技術 = [[Flash]]、[[Ruby]] }} '''どどんとふ'''は、[https://twitter.com/torgtaitai たいたい竹流氏]によって開発されているオンラインセッションツール。 == 概要 == オンラインセッションに必要な多くの機能を備えた、総合オンラインセッションツール。部屋の作成、チャット、ダイスボット、キャラクター管理、マップ管理、イニシアティブ表といった基本的な機能に加えて、以下のような豊富な機能を搭載している<ref name="official-manual">[http://www.melonbooks.com/index.php?main_page=product_info&products_id=IT0000197863 どどんとふで始める初めてのオンラインセッション2017年夏の号!]</ref>。 * 秘話チャット * シークレットダイス * ダイスシンボル * 共有メモ * カード * 資源管理 * 範囲 * 魔法タイマー * チット設置 * マップ手書き * 画像のアップロード * Webカメラ撮影 * 立ち絵 * ノベルゲーム風表示 * カットイン * 読み上げ * リプレイ録画 * 多言語対応 === ダイスボット === ダイスボットとして[[BCDice]](ボーンズ&カーズ)を使用している。現在のBCDiceは、どどんとふ環境で動作することを前提として開発、テストされている。様々なゲームシステムのダイスロールおよび表引きに加え、独自の表の追加、カード機能などBCDiceの機能をフル活用しているのは、どどんとふならではである。 == Flashの廃止に伴う影響 == どどんとふのクライアントプログラム(プレイヤーが操作する画面のプログラム)は、[[Flash]]を使用して作られている。Flashは2020年に廃止されることが決定しており、2021年以降、通常はブラウザからクライアントプログラムを動作させることができなくなる。そのため、[[どどんとふ公式鯖]]<ref>[https://twitter.com/DoDontoF_Srv/status/1112201807239901184 どどんとふ公式鯖とねこ卓公式鯖と氷丼公式鯖中の人さんのツイート: "2020年12月にどどんとふ公式鯖終了がかなり濃厚です。HTML5版を残すかは開発体制状況次第です。 Quoridornやねこ卓その他ツールは継続予定ですが、サーバー負荷は激減するけど収益も激減するのは確実なので、そこら辺をどうするかも課題です。無罪になったのにCoinhive無くなっちゃうしなあ。"]</ref>や[[どどんとふむせる]]<ref>[http://museru.blog.jp/archives/1066846255.html どどんとふ「むせる」の終了時期について : むせるいんふぉめーしょん]</ref>では、管理者が2020年にどどんとふの提供を終了することを宣言している。 なお、[[Ruby]]で書かれているどどんとふのサーバープログラムは、Flash廃止の影響を受けず、2021年以降も動作する。そのため、クライアントプログラムのみ[[HTML5]]で書き直す試みが行われている(kitt氏の[[HTML5版どどんとふ]])。HTML5版のクライアントが十分に動作するようになれば、2021年以降もどどんとふを使ってオンラインセッションを楽しむことができる可能性はある。 == 設置 == === 小規模サーバー === 以下の説明は公式マニュアル<ref name="official-manual" />を基にしている。 少人数で使用する場合は、[[Ruby]](1.8.7以上)が使えるレンタルサーバーにファイルを置き、パーミッションの設定をするだけでよい。マニュアルでは、さくらインターネットのレンタルサーバー([https://www.sakura.ne.jp/ さくらのレンタルサーバ])が推奨されている。 まず、公式サイトの[http://www.dodontof.com/index.php?option=com_content&view=article&id=246&Itemid=126 ダウンロードページ]から最新版または安定版のzipファイルをダウンロードし、展開する。さくらのレンタルサーバでアカウント名が「trpg_net」の場合、展開したファイルを以下のように配置し、パーミッションを設定する。 <pre> home +- trpg_net +- www | +- DodontoF (705) | | +- DodontoFServer.rb (705) | | +- log.txt (600) | | +- log.txt.0 (600) | | +- saveDataTempSpace (705) | | +- fileUploadSpace (705) | | +- replayDataUploadSpace (705) | +- imageUploadSpace (705) | +- smallImages (705) +- saveData (705) </pre> ファイルの配置およびパーミッション設定が完了したら、ブラウザから <code>DodontoF/DodontoFServer.rb</code> を開く。上記の例の場合、URLは <pre>http://trpg_net.sakura.ne.jp/DodontoF/DodontoFServer.rb</pre> となる。ファイルの配置およびパーミッション設定が正しくできていれば、以下のように表示される。 <syntaxhighlight lang="json"> ["「どどんとふ」の動作環境は正常に起動しています。"] </syntaxhighlight> 上記のメッセージが表示されたら、<code>DodontoF/DodontoF.swf</code> を開く。上記の例の場合、URLは <pre>http://trpg_net.sakura.ne.jp/DodontoF/DodontoF.swf</pre> となる。 === 大規模サーバー === レンタルサーバーを使う場合、快適に使用できる人数は10人程度までであり、それ以上の人数では負荷が重くなる。大規模なサーバーでは、以下のような構成とする例が多い。 * より高性能なサーバーやVPSを使う。 ** SSDを使う。 ** メモリに余裕があれば、RAMディスクを使う。 ** 必要に応じて、TCP/IPに関するLinuxカーネルのチューニングを行う。 * Webサーバーとしてnginxを使う。 * 最新のRubyを使う。 * FastCGIを使う。 ** spawn-fcgiなどでサーバープログラムを起動する。 ** Gem「fcgi」を使う。 * Gem「msgpack」を使う。 * 擬似cometモードを使わない。 設置の手順を解説している記事として、以下のものがある。 * [http://cre.jp/techblog/2016/01/27/dodontof-centos7-nginx-spawn/ クリエイターズネットワーク技術部ブログ » CentOS7+nginx+spawn-fcgi でどどんとふを動かす] ** [[TRPG.NET]]へのどどんとふの設置時の作業を基にしている。 * 大ちゃんのいろいろ雑記 - どどんとふをdebian+nginxで動かすやり方(nginxセットアップ編)@公式鯖3rdシリーズ ** [[どどんとふ公式鯖]]へのどどんとふ設置作業の記録。ハードウェアの性能を満たすのは難しいが、各要素は参考になる。 *# [https://www.taruki.com/wp/?p=6099 OS編] *# [https://www.taruki.com/wp/?p=6123 nginxセットアップ編] *# [https://www.taruki.com/wp/?p=6133 fcgi編] *# [https://www.taruki.com/wp/?p=6160 どどんとふ本体編] *# [https://www.taruki.com/wp/?p=6162 運用ツール編(最低限)] *# [https://www.taruki.com/wp/?p=6165 運用ツール編(その他)] *# [https://www.taruki.com/wp/?p=6182 運用ツール編(負荷グラフ)] == 脚注 == <references /> [[Category:TRPGツール]] {{DEFAULTSORT:ととんとふ}} 150bec60d263d1da6b2c91f5d0bcea6b1f11b875 183 167 2020-08-24T21:35:49Z 0ヴ 9 wikitext text/x-wiki {{TRPGツール概要 | image = ファイル:dodontof-screenshot.png | キャプション = どどんとふのスクリーンショット | 開発者 = [https://twitter.com/torgtaitai たいたい竹流] | 公式サイト = [http://www.dodontof.com/ どどんとふ@えくすとり~む] | 公式マニュアル = [http://www.melonbooks.com/index.php?main_page=product_info&products_id=IT0000197863 どどんとふで始める初めてのオンラインセッション2017年夏の号!] | GitHubリポジトリ = [https://github.com/torgtaitai/DodontoF torgtaitai/DodontoF] | 使用技術 = [[Flash]]、[[Ruby]] }} '''どどんとふ'''は、[https://twitter.com/torgtaitai たいたい竹流氏]によって開発されているオンラインセッションツール == 概要 == オンラインセッションに必要な多くの機能を備えた、総合オンラインセッションツール。部屋の作成、チャット、ダイスボット、キャラクター管理、マップ管理、イニシアティブ表といった基本的な機能に加えて、以下のような豊富な機能を搭載している<ref name="official-manual">[http://www.melonbooks.com/index.php?main_page=product_info&products_id=IT0000197863 どどんとふで始める初めてのオンラインセッション2017年夏の号!]</ref>。 * 秘話チャット * シークレットダイス * ダイスシンボル * 共有メモ * カード * 資源管理 * 範囲 * 魔法タイマー * チット設置 * マップ手書き * 画像のアップロード * Webカメラ撮影 * 立ち絵 * ノベルゲーム風表示 * カットイン * 読み上げ * リプレイ録画 * 多言語対応 === ダイスボット === ダイスボットとして[[BCDice]](ボーンズ&カーズ)を使用している。現在のBCDiceは、どどんとふ環境で動作することを前提として開発、テストされている。様々なゲームシステムのダイスロールおよび表引きに加え、独自の表の追加、カード機能などBCDiceの機能をフル活用しているのは、どどんとふならではである。 == Flashの廃止に伴う影響 == どどんとふのクライアントプログラム(プレイヤーが操作する画面のプログラム)は、[[Flash]]を使用して作られている。Flashは2020年に廃止されることが決定しており、2021年以降、通常はブラウザからクライアントプログラムを動作させることができなくなる。そのため、[[どどんとふ公式鯖]]<ref>[https://twitter.com/DoDontoF_Srv/status/1112201807239901184 どどんとふ公式鯖とねこ卓公式鯖と氷丼公式鯖中の人さんのツイート: "2020年12月にどどんとふ公式鯖終了がかなり濃厚です。HTML5版を残すかは開発体制状況次第です。 Quoridornやねこ卓その他ツールは継続予定ですが、サーバー負荷は激減するけど収益も激減するのは確実なので、そこら辺をどうするかも課題です。無罪になったのにCoinhive無くなっちゃうしなあ。"]</ref>や[[どどんとふむせる]]<ref>[http://museru.blog.jp/archives/1066846255.html どどんとふ「むせる」の終了時期について : むせるいんふぉめーしょん]</ref>では、管理者が2020年にどどんとふの提供を終了することを宣言している。 なお、[[Ruby]]で書かれているどどんとふのサーバープログラムは、Flash廃止の影響を受けず、2021年以降も動作する。そのため、クライアントプログラムのみ[[HTML5]]で書き直す試みが行われている(kitt氏の[[HTML5版どどんとふ]])。HTML5版のクライアントが十分に動作するようになれば、2021年以降もどどんとふを使ってオンラインセッションを楽しむことができる可能性はある。 == 設置 == === 小規模サーバー === 以下の説明は公式マニュアル<ref name="official-manual" />を基にしている。 少人数で使用する場合は、[[Ruby]](1.8.7以上)が使えるレンタルサーバーにファイルを置き、パーミッションの設定をするだけでよい。マニュアルでは、さくらインターネットのレンタルサーバー([https://www.sakura.ne.jp/ さくらのレンタルサーバ])が推奨されている。 まず、公式サイトの[http://www.dodontof.com/index.php?option=com_content&view=article&id=246&Itemid=126 ダウンロードページ]から最新版または安定版のzipファイルをダウンロードし、展開する。さくらのレンタルサーバでアカウント名が「trpg_net」の場合、展開したファイルを以下のように配置し、パーミッションを設定する。 <pre> home +- trpg_net +- www | +- DodontoF (705) | | +- DodontoFServer.rb (705) | | +- log.txt (600) | | +- log.txt.0 (600) | | +- saveDataTempSpace (705) | | +- fileUploadSpace (705) | | +- replayDataUploadSpace (705) | +- imageUploadSpace (705) | +- smallImages (705) +- saveData (705) </pre> ファイルの配置およびパーミッション設定が完了したら、ブラウザから <code>DodontoF/DodontoFServer.rb</code> を開く。上記の例の場合、URLは <pre>http://trpg_net.sakura.ne.jp/DodontoF/DodontoFServer.rb</pre> となる。ファイルの配置およびパーミッション設定が正しくできていれば、以下のように表示される。 <syntaxhighlight lang="json"> ["「どどんとふ」の動作環境は正常に起動しています。"] </syntaxhighlight> 上記のメッセージが表示されたら、<code>DodontoF/DodontoF.swf</code> を開く。上記の例の場合、URLは <pre>http://trpg_net.sakura.ne.jp/DodontoF/DodontoF.swf</pre> となる。 === 大規模サーバー === レンタルサーバーを使う場合、快適に使用できる人数は10人程度までであり、それ以上の人数では負荷が重くなる。大規模なサーバーでは、以下のような構成とする例が多い。 * より高性能なサーバーやVPSを使う。 ** SSDを使う。 ** メモリに余裕があれば、RAMディスクを使う。 ** 必要に応じて、TCP/IPに関するLinuxカーネルのチューニングを行う。 * Webサーバーとしてnginxを使う。 * 最新のRubyを使う。 * FastCGIを使う。 ** spawn-fcgiなどでサーバープログラムを起動する。 ** Gem「fcgi」を使う。 * Gem「msgpack」を使う。 * 擬似cometモードを使わない。 設置の手順を解説している記事として、以下のものがある。 * [http://cre.jp/techblog/2016/01/27/dodontof-centos7-nginx-spawn/ クリエイターズネットワーク技術部ブログ » CentOS7+nginx+spawn-fcgi でどどんとふを動かす] ** [[TRPG.NET]]へのどどんとふの設置時の作業を基にしている。 * 大ちゃんのいろいろ雑記 - どどんとふをdebian+nginxで動かすやり方(nginxセットアップ編)@公式鯖3rdシリーズ ** [[どどんとふ公式鯖]]へのどどんとふ設置作業の記録。ハードウェアの性能を満たすのは難しいが、各要素は参考になる。 *# [https://www.taruki.com/wp/?p=6099 OS編] *# [https://www.taruki.com/wp/?p=6123 nginxセットアップ編] *# [https://www.taruki.com/wp/?p=6133 fcgi編] *# [https://www.taruki.com/wp/?p=6160 どどんとふ本体編] *# [https://www.taruki.com/wp/?p=6162 運用ツール編(最低限)] *# [https://www.taruki.com/wp/?p=6165 運用ツール編(その他)] *# [https://www.taruki.com/wp/?p=6182 運用ツール編(負荷グラフ)] == 脚注 == <references /> [[Category:TRPGツール]] {{DEFAULTSORT:ととんとふ}} 63daab96314db30bdc1db381c4065cb91237e807 204 183 2020-08-26T22:42:41Z 2400:4153:84E0:AC00:B5C3:DB95:924F:6C8E 0 [[Special:Contributions/0ヴ|0ヴ]] ([[User talk:0ヴ|トーク]]) による版 183 を取り消し wikitext text/x-wiki {{TRPGツール概要 | image = ファイル:dodontof-screenshot.png | キャプション = どどんとふのスクリーンショット | 開発者 = [https://twitter.com/torgtaitai たいたい竹流] | 公式サイト = [http://www.dodontof.com/ どどんとふ@えくすとり~む] | 公式マニュアル = [http://www.melonbooks.com/index.php?main_page=product_info&products_id=IT0000197863 どどんとふで始める初めてのオンラインセッション2017年夏の号!] | GitHubリポジトリ = [https://github.com/torgtaitai/DodontoF torgtaitai/DodontoF] | 使用技術 = [[Flash]]、[[Ruby]] }} '''どどんとふ'''は、[https://twitter.com/torgtaitai たいたい竹流氏]によって開発されているオンラインセッションツール。 == 概要 == オンラインセッションに必要な多くの機能を備えた、総合オンラインセッションツール。部屋の作成、チャット、ダイスボット、キャラクター管理、マップ管理、イニシアティブ表といった基本的な機能に加えて、以下のような豊富な機能を搭載している<ref name="official-manual">[http://www.melonbooks.com/index.php?main_page=product_info&products_id=IT0000197863 どどんとふで始める初めてのオンラインセッション2017年夏の号!]</ref>。 * 秘話チャット * シークレットダイス * ダイスシンボル * 共有メモ * カード * 資源管理 * 範囲 * 魔法タイマー * チット設置 * マップ手書き * 画像のアップロード * Webカメラ撮影 * 立ち絵 * ノベルゲーム風表示 * カットイン * 読み上げ * リプレイ録画 * 多言語対応 === ダイスボット === ダイスボットとして[[BCDice]](ボーンズ&カーズ)を使用している。現在のBCDiceは、どどんとふ環境で動作することを前提として開発、テストされている。様々なゲームシステムのダイスロールおよび表引きに加え、独自の表の追加、カード機能などBCDiceの機能をフル活用しているのは、どどんとふならではである。 == Flashの廃止に伴う影響 == どどんとふのクライアントプログラム(プレイヤーが操作する画面のプログラム)は、[[Flash]]を使用して作られている。Flashは2020年に廃止されることが決定しており、2021年以降、通常はブラウザからクライアントプログラムを動作させることができなくなる。そのため、[[どどんとふ公式鯖]]<ref>[https://twitter.com/DoDontoF_Srv/status/1112201807239901184 どどんとふ公式鯖とねこ卓公式鯖と氷丼公式鯖中の人さんのツイート: "2020年12月にどどんとふ公式鯖終了がかなり濃厚です。HTML5版を残すかは開発体制状況次第です。 Quoridornやねこ卓その他ツールは継続予定ですが、サーバー負荷は激減するけど収益も激減するのは確実なので、そこら辺をどうするかも課題です。無罪になったのにCoinhive無くなっちゃうしなあ。"]</ref>や[[どどんとふむせる]]<ref>[http://museru.blog.jp/archives/1066846255.html どどんとふ「むせる」の終了時期について : むせるいんふぉめーしょん]</ref>では、管理者が2020年にどどんとふの提供を終了することを宣言している。 なお、[[Ruby]]で書かれているどどんとふのサーバープログラムは、Flash廃止の影響を受けず、2021年以降も動作する。そのため、クライアントプログラムのみ[[HTML5]]で書き直す試みが行われている(kitt氏の[[HTML5版どどんとふ]])。HTML5版のクライアントが十分に動作するようになれば、2021年以降もどどんとふを使ってオンラインセッションを楽しむことができる可能性はある。 == 設置 == === 小規模サーバー === 以下の説明は公式マニュアル<ref name="official-manual" />を基にしている。 少人数で使用する場合は、[[Ruby]](1.8.7以上)が使えるレンタルサーバーにファイルを置き、パーミッションの設定をするだけでよい。マニュアルでは、さくらインターネットのレンタルサーバー([https://www.sakura.ne.jp/ さくらのレンタルサーバ])が推奨されている。 まず、公式サイトの[http://www.dodontof.com/index.php?option=com_content&view=article&id=246&Itemid=126 ダウンロードページ]から最新版または安定版のzipファイルをダウンロードし、展開する。さくらのレンタルサーバでアカウント名が「trpg_net」の場合、展開したファイルを以下のように配置し、パーミッションを設定する。 <pre> home +- trpg_net +- www | +- DodontoF (705) | | +- DodontoFServer.rb (705) | | +- log.txt (600) | | +- log.txt.0 (600) | | +- saveDataTempSpace (705) | | +- fileUploadSpace (705) | | +- replayDataUploadSpace (705) | +- imageUploadSpace (705) | +- smallImages (705) +- saveData (705) </pre> ファイルの配置およびパーミッション設定が完了したら、ブラウザから <code>DodontoF/DodontoFServer.rb</code> を開く。上記の例の場合、URLは <pre>http://trpg_net.sakura.ne.jp/DodontoF/DodontoFServer.rb</pre> となる。ファイルの配置およびパーミッション設定が正しくできていれば、以下のように表示される。 <syntaxhighlight lang="json"> ["「どどんとふ」の動作環境は正常に起動しています。"] </syntaxhighlight> 上記のメッセージが表示されたら、<code>DodontoF/DodontoF.swf</code> を開く。上記の例の場合、URLは <pre>http://trpg_net.sakura.ne.jp/DodontoF/DodontoF.swf</pre> となる。 === 大規模サーバー === レンタルサーバーを使う場合、快適に使用できる人数は10人程度までであり、それ以上の人数では負荷が重くなる。大規模なサーバーでは、以下のような構成とする例が多い。 * より高性能なサーバーやVPSを使う。 ** SSDを使う。 ** メモリに余裕があれば、RAMディスクを使う。 ** 必要に応じて、TCP/IPに関するLinuxカーネルのチューニングを行う。 * Webサーバーとしてnginxを使う。 * 最新のRubyを使う。 * FastCGIを使う。 ** spawn-fcgiなどでサーバープログラムを起動する。 ** Gem「fcgi」を使う。 * Gem「msgpack」を使う。 * 擬似cometモードを使わない。 設置の手順を解説している記事として、以下のものがある。 * [http://cre.jp/techblog/2016/01/27/dodontof-centos7-nginx-spawn/ クリエイターズネットワーク技術部ブログ » CentOS7+nginx+spawn-fcgi でどどんとふを動かす] ** [[TRPG.NET]]へのどどんとふの設置時の作業を基にしている。 * 大ちゃんのいろいろ雑記 - どどんとふをdebian+nginxで動かすやり方(nginxセットアップ編)@公式鯖3rdシリーズ ** [[どどんとふ公式鯖]]へのどどんとふ設置作業の記録。ハードウェアの性能を満たすのは難しいが、各要素は参考になる。 *# [https://www.taruki.com/wp/?p=6099 OS編] *# [https://www.taruki.com/wp/?p=6123 nginxセットアップ編] *# [https://www.taruki.com/wp/?p=6133 fcgi編] *# [https://www.taruki.com/wp/?p=6160 どどんとふ本体編] *# [https://www.taruki.com/wp/?p=6162 運用ツール編(最低限)] *# [https://www.taruki.com/wp/?p=6165 運用ツール編(その他)] *# [https://www.taruki.com/wp/?p=6182 運用ツール編(負荷グラフ)] == 脚注 == <references /> [[Category:TRPGツール]] {{DEFAULTSORT:ととんとふ}} 150bec60d263d1da6b2c91f5d0bcea6b1f11b875 BCDice/TRPGツールからの呼び出し方/BCDice-API 0 17 168 120 2020-08-23T03:19:31Z 118.10.82.175 0 [[Special:Contributions/Ochaochaocha3|Ochaochaocha3]] ([[User talk:Ochaochaocha3|トーク]]) による版 120 を取り消し wikitext text/x-wiki [[BCDice-API]]からの[[BCDice]]の呼び出し方。[https://github.com/ysakasin/bcdice-api/releases/tag/0.6.2 v0.6.2]のソースコードを参考にしている。 == server.rb L74-L78 == https://github.com/ysakasin/bcdice-api/blob/0dfd095a4c7befed58ffbb7eb880a9d729badf2a/server.rb#L74-L78 パス `/v1/diceroll` にリクエストが来たときの処理。ダイスロールを行う。 <syntaxhighlight lang="ruby"> get "/v1/diceroll" do result, secret, dices = diceroll(params[:system], params[:command]) jsonp ok: true, result: result, secret: secret, dices: dices end </syntaxhighlight> == server.rb L20-L42 == https://github.com/ysakasin/bcdice-api/blob/0dfd095a4c7befed58ffbb7eb880a9d729badf2a/server.rb#L20-L42 ダイスロールを行うメソッド。 <syntaxhighlight lang="ruby"> def diceroll(system, command) dicebot = BCDice::DICEBOTS[system] if dicebot.nil? raise UnsupportedDicebot end if command.nil? || command.empty? raise CommandError end bcdice = BCDiceMaker.new.newBcDice bcdice.setDiceBot(dicebot) bcdice.setMessage(command) bcdice.setCollectRandResult(true) result, secret = bcdice.dice_command dices = bcdice.getRandResults.map {|dice| {faces: dice[1], value: dice[0]}} if result.nil? raise CommandError end return result, secret, dices end </syntaxhighlight> [[Category:BCDice/TRPGツールからの呼び出し方]] 2627e6e14c08a1283e028a53200a39d3117c3b02 184 168 2020-08-24T21:36:59Z 0ヴ 9 wikitext text/x-wiki [[BCDice-API]]からの[[BCDice]]の呼び出し方。[https://github.com/ysakasin/bcdice-api/releases/tag/0.6.2 v0.6.2]のソースコードを参考にしている == server.rb L74-L78 == https://github.com/ysakasin/bcdice-api/blob/0dfd095a4c7befed58ffbb7eb880a9d729badf2a/server.rb#L74-L78 パス `/v1/diceroll` にリクエストが来たときの処理。ダイスロールを行う。 <syntaxhighlight lang="ruby"> get "/v1/diceroll" do result, secret, dices = diceroll(params[:system], params[:command]) jsonp ok: true, result: result, secret: secret, dices: dices end </syntaxhighlight> == server.rb L20-L42 == https://github.com/ysakasin/bcdice-api/blob/0dfd095a4c7befed58ffbb7eb880a9d729badf2a/server.rb#L20-L42 ダイスロールを行うメソッド。 <syntaxhighlight lang="ruby"> def diceroll(system, command) dicebot = BCDice::DICEBOTS[system] if dicebot.nil? raise UnsupportedDicebot end if command.nil? || command.empty? raise CommandError end bcdice = BCDiceMaker.new.newBcDice bcdice.setDiceBot(dicebot) bcdice.setMessage(command) bcdice.setCollectRandResult(true) result, secret = bcdice.dice_command dices = bcdice.getRandResults.map {|dice| {faces: dice[1], value: dice[0]}} if result.nil? raise CommandError end return result, secret, dices end </syntaxhighlight> [[Category:BCDice/TRPGツールからの呼び出し方]] e52e4c1dc98dad2e1ee0b126b7253c43cefd7f62 205 184 2020-08-26T22:43:31Z 2400:4153:84E0:AC00:B5C3:DB95:924F:6C8E 0 [[Special:Contributions/0ヴ|0ヴ]] ([[User talk:0ヴ|トーク]]) による版 184 を取り消し wikitext text/x-wiki [[BCDice-API]]からの[[BCDice]]の呼び出し方。[https://github.com/ysakasin/bcdice-api/releases/tag/0.6.2 v0.6.2]のソースコードを参考にしている。 == server.rb L74-L78 == https://github.com/ysakasin/bcdice-api/blob/0dfd095a4c7befed58ffbb7eb880a9d729badf2a/server.rb#L74-L78 パス `/v1/diceroll` にリクエストが来たときの処理。ダイスロールを行う。 <syntaxhighlight lang="ruby"> get "/v1/diceroll" do result, secret, dices = diceroll(params[:system], params[:command]) jsonp ok: true, result: result, secret: secret, dices: dices end </syntaxhighlight> == server.rb L20-L42 == https://github.com/ysakasin/bcdice-api/blob/0dfd095a4c7befed58ffbb7eb880a9d729badf2a/server.rb#L20-L42 ダイスロールを行うメソッド。 <syntaxhighlight lang="ruby"> def diceroll(system, command) dicebot = BCDice::DICEBOTS[system] if dicebot.nil? raise UnsupportedDicebot end if command.nil? || command.empty? raise CommandError end bcdice = BCDiceMaker.new.newBcDice bcdice.setDiceBot(dicebot) bcdice.setMessage(command) bcdice.setCollectRandResult(true) result, secret = bcdice.dice_command dices = bcdice.getRandResults.map {|dice| {faces: dice[1], value: dice[0]}} if result.nil? raise CommandError end return result, secret, dices end </syntaxhighlight> [[Category:BCDice/TRPGツールからの呼び出し方]] 2627e6e14c08a1283e028a53200a39d3117c3b02 BCDice/TRPGツールからの呼び出し方/Onset! 0 21 169 121 2020-08-23T20:25:01Z 118.10.82.175 0 [[Special:Contributions/Ochaochaocha3|Ochaochaocha3]] ([[User talk:Ochaochaocha3|トーク]]) による版 121 を取り消し wikitext text/x-wiki [[Onset!]]からの[[BCDice]]の呼び出し方。[https://github.com/kiridaruma/Onset/releases/tag/v2.1.3 v2.1.3]のソースコードを参考にしている。 ツール本体は[[PHP]]製だが、[[Ruby]]で書かれた簡潔なラッパースクリプトを[[CGI]]で呼び出している。 __TOC__ == Onset/public_html/bcdice/roll.rb L31-L36 == https://github.com/kiridaruma/Onset/blob/297e66de6b799198cdf17036e12f89c7506fcd65/Onset/public_html/bcdice/roll.rb#L31-L36 クエリパラメータ <code>list=1</code> がついていた場合、ゲームシステム一覧を出力する。 <syntaxhighlight lang="ruby"> if(params['list'][0] == "1") $allGameTypes.each do |var| puts var + "\n" end exit end </syntaxhighlight> == Onset/public_html/bcdice/roll.rb L47-L55 == https://github.com/kiridaruma/Onset/blob/297e66de6b799198cdf17055e12f89c7506fcd65/Onset/public_html/bcdice/roll.rb#L47-L55 ダイスロールを行う。 <syntaxhighlight lang="ruby"> bcmaker = OnsetBCDiceMaker.new bcdice = bcmaker.newBcDice() bcdice.setGameByTitle(params['sys'][0]) bcdice.setMessage(params['text'][0]) bcdice.setNick('onset') hoge, foo = bcdice.dice_command puts hoge </syntaxhighlight> == Onset/public_html/bcdice/roll.rb L11-L24 == https://github.com/kiridaruma/Onset/blob/297e66de6b799198cdf17055e12f89c7506fcd65/Onset/public_html/bcdice/roll.rb#L11-L24 <code>OnsetBCDice</code> クラスは、Onset!のインターフェースに合わせてニックネームを設定する機能を付加している。<code>OnsetBCDiceMaker</code> クラスは、BCDiceのインスタンス作成時に <code>OnsetBCDice</code> クラスを使うようにする。 <syntaxhighlight lang="ruby"> class OnsetBCDiceMaker < BCDiceMaker def newBcDice bcdice = OnsetBCDice.new(self, @cardTrader, @diceBot, @counterInfos, @tableFileData) return bcdice end end class OnsetBCDice < BCDice def setNick(nick) @nick_e = nick end end </syntaxhighlight> [[Category:BCDice/TRPGツールからの呼び出し方]] 202438f5154e02f8e0c460bb9f469305e58bca32 185 169 2020-08-24T21:38:35Z 0ヴ 9 wikitext text/x-wiki [[Onset!]]からの[[BCDice]]の呼び出し方。[https://github.com/kiridaruma/Onset/releases/tag/v2.1.3 v2.1.3]のソースコードを参考にしている。 ツール本体は[[PHP]]製だが、[[Ruby]]で書かれた簡潔なラッパースクリプトを[[CGI]]で呼び出している。 __TOC_ == Onset/public_html/bcdice/roll.rb L31-L36 == https://github.com/kiridaruma/Onset/blob/297e66de6b799198cdf17036e12f89c7506fcd65/Onset/public_html/bcdice/roll.rb#L31-L36 クエリパラメータ <code>list=1</code> がついていた場合、ゲームシステム一覧を出力する。 <syntaxhighlight lang="ruby"> if(params['list'][0] == "1") $allGameTypes.each do |var| puts var + "\n" end exit end </syntaxhighlight> == Onset/public_html/bcdice/roll.rb L47-L55 == https://github.com/kiridaruma/Onset/blob/297e66de6b799198cdf17055e12f89c7506fcd65/Onset/public_html/bcdice/roll.rb#L47-L55 ダイスロールを行う。 <syntaxhighlight lang="ruby"> bcmaker = OnsetBCDiceMaker.new bcdice = bcmaker.newBcDice() bcdice.setGameByTitle(params['sys'][0]) bcdice.setMessage(params['text'][0]) bcdice.setNick('onset') hoge, foo = bcdice.dice_command puts hoge </syntaxhighlight> == Onset/public_html/bcdice/roll.rb L11-L24 == https://github.com/kiridaruma/Onset/blob/297e66de6b799198cdf17055e12f89c7506fcd65/Onset/public_html/bcdice/roll.rb#L11-L24 <code>OnsetBCDice</code> クラスは、Onset!のインターフェースに合わせてニックネームを設定する機能を付加している。<code>OnsetBCDiceMaker</code> クラスは、BCDiceのインスタンス作成時に <code>OnsetBCDice</code> クラスを使うようにする。 <syntaxhighlight lang="ruby"> class OnsetBCDiceMaker < BCDiceMaker def newBcDice bcdice = OnsetBCDice.new(self, @cardTrader, @diceBot, @counterInfos, @tableFileData) return bcdice end end class OnsetBCDice < BCDice def setNick(nick) @nick_e = nick end end </syntaxhighlight> [[Category:BCDice/TRPGツールからの呼び出し方]] 55813a8fe25d45ef72c0a7f1ad0c8ee5387a9f35 206 185 2020-08-26T22:44:09Z 2400:4153:84E0:AC00:B5C3:DB95:924F:6C8E 0 [[Special:Contributions/0ヴ|0ヴ]] ([[User talk:0ヴ|トーク]]) による版 185 を取り消し wikitext text/x-wiki [[Onset!]]からの[[BCDice]]の呼び出し方。[https://github.com/kiridaruma/Onset/releases/tag/v2.1.3 v2.1.3]のソースコードを参考にしている。 ツール本体は[[PHP]]製だが、[[Ruby]]で書かれた簡潔なラッパースクリプトを[[CGI]]で呼び出している。 __TOC__ == Onset/public_html/bcdice/roll.rb L31-L36 == https://github.com/kiridaruma/Onset/blob/297e66de6b799198cdf17036e12f89c7506fcd65/Onset/public_html/bcdice/roll.rb#L31-L36 クエリパラメータ <code>list=1</code> がついていた場合、ゲームシステム一覧を出力する。 <syntaxhighlight lang="ruby"> if(params['list'][0] == "1") $allGameTypes.each do |var| puts var + "\n" end exit end </syntaxhighlight> == Onset/public_html/bcdice/roll.rb L47-L55 == https://github.com/kiridaruma/Onset/blob/297e66de6b799198cdf17055e12f89c7506fcd65/Onset/public_html/bcdice/roll.rb#L47-L55 ダイスロールを行う。 <syntaxhighlight lang="ruby"> bcmaker = OnsetBCDiceMaker.new bcdice = bcmaker.newBcDice() bcdice.setGameByTitle(params['sys'][0]) bcdice.setMessage(params['text'][0]) bcdice.setNick('onset') hoge, foo = bcdice.dice_command puts hoge </syntaxhighlight> == Onset/public_html/bcdice/roll.rb L11-L24 == https://github.com/kiridaruma/Onset/blob/297e66de6b799198cdf17055e12f89c7506fcd65/Onset/public_html/bcdice/roll.rb#L11-L24 <code>OnsetBCDice</code> クラスは、Onset!のインターフェースに合わせてニックネームを設定する機能を付加している。<code>OnsetBCDiceMaker</code> クラスは、BCDiceのインスタンス作成時に <code>OnsetBCDice</code> クラスを使うようにする。 <syntaxhighlight lang="ruby"> class OnsetBCDiceMaker < BCDiceMaker def newBcDice bcdice = OnsetBCDice.new(self, @cardTrader, @diceBot, @counterInfos, @tableFileData) return bcdice end end class OnsetBCDice < BCDice def setNick(nick) @nick_e = nick end end </syntaxhighlight> [[Category:BCDice/TRPGツールからの呼び出し方]] 202438f5154e02f8e0c460bb9f469305e58bca32 irc.cre.jp系 0 52 170 141 2020-08-24T09:19:29Z 118.10.82.175 0 [[Special:Contributions/Ochaochaocha3|Ochaochaocha3]] ([[User talk:Ochaochaocha3|トーク]]) による版 141 を取り消し wikitext text/x-wiki 「irc.cre.jp系IRCサーバ群」を正式名称とする、[[クリエイターズネットワーク]]が提供する[[IRC]]ネットワークである。旧称「TRPG.NET系」。 2019年現在、日本には他に、独立系のIRCネットワークとしてFriendChat系や[https://www.irc.city.tokyo-3.jp/ 第3新東京市]系などがある。これらのIRCネットワークと比較したときの特徴は以下の通りである。 * 利用可能なニックネームが長い(31文字まで使用可能。プロトコル上は9文字まで、他の多くのネットワークでは25文字まで) * ダイス機能を含む公式のボットが提供されている([[Toybox/Role]]) * チャットには、一部の環境依存文字を含む、多くの文字が使用可能(UTF-8 を採用している) * IRC プロトコルの標準的なサーバ(ircd2.11)を使っていない * [[NickServ]] などの、管理サービスが使用可能 ef461f919e1bbecbdf033130f78531716c574905 186 170 2020-08-24T21:39:44Z 0ヴ 9 wikitext text/x-wiki 「irc.cre.jp系IRCサーバ群」を正式名称とする、[[クリエイターズネットワーク]]が提供する[[IRC]]ネットワークである。旧称「TRPG.NET系」。 2019年現在、日本には他に、独立系のIRCネットワークとしてFriendChat系や[https://www.irc.city.tokyo-3.jp/ 第3新東京市]系などがある。これらのIRCネットワークと比較したときの特徴は以下の通りである。 * 利用可能なニックネームが長い(31文字まで使用可能。プロトコル上は9文字まで、他の多くのネットワークでは25文字まで) * ダイス機能を含む公式のボットが提供されている([[Toybox/Role]]) * チャットには、一部の環境依存文字を含む、多くの文字が使用可能(UTF-8 を採用している) * IRC プロトコルの標準的なサーバ(ircd2.11)を使っていない * [[NickServ]] などの、管理サービスが使用可 24ca1bbbd767f3ce25215c8dae83cf88050c1a50 207 186 2020-08-26T22:45:02Z 2400:4153:84E0:AC00:B5C3:DB95:924F:6C8E 0 [[Special:Contributions/0ヴ|0ヴ]] ([[User talk:0ヴ|トーク]]) による版 186 を取り消し wikitext text/x-wiki 「irc.cre.jp系IRCサーバ群」を正式名称とする、[[クリエイターズネットワーク]]が提供する[[IRC]]ネットワークである。旧称「TRPG.NET系」。 2019年現在、日本には他に、独立系のIRCネットワークとしてFriendChat系や[https://www.irc.city.tokyo-3.jp/ 第3新東京市]系などがある。これらのIRCネットワークと比較したときの特徴は以下の通りである。 * 利用可能なニックネームが長い(31文字まで使用可能。プロトコル上は9文字まで、他の多くのネットワークでは25文字まで) * ダイス機能を含む公式のボットが提供されている([[Toybox/Role]]) * チャットには、一部の環境依存文字を含む、多くの文字が使用可能(UTF-8 を採用している) * IRC プロトコルの標準的なサーバ(ircd2.11)を使っていない * [[NickServ]] などの、管理サービスが使用可能 ef461f919e1bbecbdf033130f78531716c574905 BCDice/TRPGツールからの呼び出し方/オンセンルーム 0 22 173 46 2020-08-24T21:17:49Z 0ヴ 9 /* rb/plug.rb L6-L13 */ wikitext text/x-wiki [[オンセンルーム]]からの[[BCDice]]の呼び出し方。v1.01.07のソースコードを参考にしている。 ツール本体は[[PHP]]製だが、[[Ruby]]で書かれた簡潔なラッパースクリプトを[[CGI]]で呼び出している。 == rb/plug.rb L6-L13 == 初期設定。CGIで送られてきたフラグを変数に格納している。<code>"0"</code> だとダイスロールを行い、<code>"1"</code> だとダイスボットの説明文を取得する。 <syntaxhighlight lang="ruby"> cgi=CGI.new flag="0" #0=roll 1=descript bclocation='../BCDice/src' dicebot_name='DiceBot' dicebot_command='' if !cgi['flag'].nil? && !cgi['flag'].empty? then flag=cgi['flag'] end </syntaxhighlight == rb/plug.rb L54-L60 == 共通設定。 <syntaxhighlight lang="ruby"> bcdiceMarker=OnsenBCDiceMaker.new bcdice=bcdiceMarker.newBcDice() bcdice.setCollectRandResult(true); if File.exist?(bclocation+'/extratables') then bcdice.setDir(bclocation+'/extratables',dicebot_name) end bcdice.setGameByTitle(dicebot_name) </syntaxhighlight> == rb/plug.rb L61-L71 == ダイスロールを行う。 <syntaxhighlight lang="ruby"> if flag !="1" then bcdice.setMessage(dicebot_command) gmsg=bcdice.getMessage res_msg,secret_flag=bcdice.dice_command res_rand=bcdice.getRandResults json_array={ 'secret_flag'=>secret_flag, 'gmsg'=>gmsg, 'res_rand'=>res_rand, 'res_msg'=>res_msg } </syntaxhighlight> == rb/plug.rb L72-L77 == ダイスボットの説明文を取得する。 <syntaxhighlight lang="ruby"> else ght=bcdice.gotHelpMessage json_array={ 'ght'=>ght } end </syntaxhighlight> == rb/plug.rb L40-L53 == 独自クラスの定義。必要な機能を呼び出しやすくしているようだ。 <syntaxhighlight lang="ruby"> class OnsenBCDiceMaker<BCDiceMaker def newBcDice bcdice=OnsenBCDice.new(self,@cardTrader,@diceBot,@counterInfos,@tableFileData) return bcdice end end class OnsenBCDice<BCDice def getMessage return @message end def gotHelpMessage return @diceBot.getHelpMessage end end </syntaxhighlight> == rb/plug.rb のソースコード == アーカイブを展開しないと見られないため、rb/plug.rb のソースコードを以下に掲載する。ただし、インデントのためのタブとスペースが混在していたため、スペースのみに直してある。 <syntaxhighlight lang="ruby"> #!/bin/ruby -Ku print("Content-Type: text/plain;charset=utf-8\n\n") require 'json.rb' require 'cgi.rb' cgi=CGI.new flag="0" #0=roll 1=descript bclocation='../BCDice/src' dicebot_name='DiceBot' dicebot_command='' if !cgi['flag'].nil? && !cgi['flag'].empty? then flag=cgi['flag'] end if !cgi['bclocation'].nil? && !cgi['bclocation'].empty? then bclocation=cgi['bclocation']+'src' end if !File.exist?(bclocation) then json_array={ 'error'=>'bac_location_error' } puts json_array.to_json exit end $LOAD_PATH<<bclocation if !cgi['dicebot_name'].nil? && !cgi['dicebot_name'].empty? then dicebot_name=cgi['dicebot_name'] end if !cgi['dicebot_command'].nil? && !cgi['dicebot_command'].empty? then dicebot_command=cgi['dicebot_command'] end if flag !="1" && dicebot_command=='' then json_array={ 'error'=>'not_exist_command' } puts json_array.to_json exit end require 'bcdiceCore.rb' require 'configBcDice.rb' class OnsenBCDiceMaker<BCDiceMaker def newBcDice bcdice=OnsenBCDice.new(self,@cardTrader,@diceBot,@counterInfos,@tableFileData) return bcdice end end class OnsenBCDice<BCDice def getMessage return @message end def gotHelpMessage return @diceBot.getHelpMessage end end bcdiceMarker=OnsenBCDiceMaker.new bcdice=bcdiceMarker.newBcDice() bcdice.setCollectRandResult(true); if File.exist?(bclocation+'/extratables') then bcdice.setDir(bclocation+'/extratables',dicebot_name) end bcdice.setGameByTitle(dicebot_name) if flag !="1" then bcdice.setMessage(dicebot_command) gmsg=bcdice.getMessage res_msg,secret_flag=bcdice.dice_command res_rand=bcdice.getRandResults json_array={ 'secret_flag'=>secret_flag, 'gmsg'=>gmsg, 'res_rand'=>res_rand, 'res_msg'=>res_msg } else ght=bcdice.gotHelpMessage json_array={ 'ght'=>ght } end puts json_array.to_json </syntaxhighlight> [[Category:BCDice/TRPGツールからの呼び出し方]] {{DEFAULTSORT:おんせんるうむ}} 367c1fb6fb10d204053b64dc1f6036562f3cb1ce 188 173 2020-08-24T22:42:08Z 118.10.82.175 0 [[Special:Contributions/0ヴ|0ヴ]] ([[User talk:0ヴ|トーク]]) による版 173 を取り消し wikitext text/x-wiki [[オンセンルーム]]からの[[BCDice]]の呼び出し方。v1.01.07のソースコードを参考にしている。 ツール本体は[[PHP]]製だが、[[Ruby]]で書かれた簡潔なラッパースクリプトを[[CGI]]で呼び出している。 == rb/plug.rb L6-L13 == 初期設定。CGIで送られてきたフラグを変数に格納している。<code>"0"</code> だとダイスロールを行い、<code>"1"</code> だとダイスボットの説明文を取得する。 <syntaxhighlight lang="ruby"> cgi=CGI.new flag="0" #0=roll 1=descript bclocation='../BCDice/src' dicebot_name='DiceBot' dicebot_command='' if !cgi['flag'].nil? && !cgi['flag'].empty? then flag=cgi['flag'] end </syntaxhighlight> == rb/plug.rb L54-L60 == 共通設定。 <syntaxhighlight lang="ruby"> bcdiceMarker=OnsenBCDiceMaker.new bcdice=bcdiceMarker.newBcDice() bcdice.setCollectRandResult(true); if File.exist?(bclocation+'/extratables') then bcdice.setDir(bclocation+'/extratables',dicebot_name) end bcdice.setGameByTitle(dicebot_name) </syntaxhighlight> == rb/plug.rb L61-L71 == ダイスロールを行う。 <syntaxhighlight lang="ruby"> if flag !="1" then bcdice.setMessage(dicebot_command) gmsg=bcdice.getMessage res_msg,secret_flag=bcdice.dice_command res_rand=bcdice.getRandResults json_array={ 'secret_flag'=>secret_flag, 'gmsg'=>gmsg, 'res_rand'=>res_rand, 'res_msg'=>res_msg } </syntaxhighlight> == rb/plug.rb L72-L77 == ダイスボットの説明文を取得する。 <syntaxhighlight lang="ruby"> else ght=bcdice.gotHelpMessage json_array={ 'ght'=>ght } end </syntaxhighlight> == rb/plug.rb L40-L53 == 独自クラスの定義。必要な機能を呼び出しやすくしているようだ。 <syntaxhighlight lang="ruby"> class OnsenBCDiceMaker<BCDiceMaker def newBcDice bcdice=OnsenBCDice.new(self,@cardTrader,@diceBot,@counterInfos,@tableFileData) return bcdice end end class OnsenBCDice<BCDice def getMessage return @message end def gotHelpMessage return @diceBot.getHelpMessage end end </syntaxhighlight> == rb/plug.rb のソースコード == アーカイブを展開しないと見られないため、rb/plug.rb のソースコードを以下に掲載する。ただし、インデントのためのタブとスペースが混在していたため、スペースのみに直してある。 <syntaxhighlight lang="ruby"> #!/bin/ruby -Ku print("Content-Type: text/plain;charset=utf-8\n\n") require 'json.rb' require 'cgi.rb' cgi=CGI.new flag="0" #0=roll 1=descript bclocation='../BCDice/src' dicebot_name='DiceBot' dicebot_command='' if !cgi['flag'].nil? && !cgi['flag'].empty? then flag=cgi['flag'] end if !cgi['bclocation'].nil? && !cgi['bclocation'].empty? then bclocation=cgi['bclocation']+'src' end if !File.exist?(bclocation) then json_array={ 'error'=>'bac_location_error' } puts json_array.to_json exit end $LOAD_PATH<<bclocation if !cgi['dicebot_name'].nil? && !cgi['dicebot_name'].empty? then dicebot_name=cgi['dicebot_name'] end if !cgi['dicebot_command'].nil? && !cgi['dicebot_command'].empty? then dicebot_command=cgi['dicebot_command'] end if flag !="1" && dicebot_command=='' then json_array={ 'error'=>'not_exist_command' } puts json_array.to_json exit end require 'bcdiceCore.rb' require 'configBcDice.rb' class OnsenBCDiceMaker<BCDiceMaker def newBcDice bcdice=OnsenBCDice.new(self,@cardTrader,@diceBot,@counterInfos,@tableFileData) return bcdice end end class OnsenBCDice<BCDice def getMessage return @message end def gotHelpMessage return @diceBot.getHelpMessage end end bcdiceMarker=OnsenBCDiceMaker.new bcdice=bcdiceMarker.newBcDice() bcdice.setCollectRandResult(true); if File.exist?(bclocation+'/extratables') then bcdice.setDir(bclocation+'/extratables',dicebot_name) end bcdice.setGameByTitle(dicebot_name) if flag !="1" then bcdice.setMessage(dicebot_command) gmsg=bcdice.getMessage res_msg,secret_flag=bcdice.dice_command res_rand=bcdice.getRandResults json_array={ 'secret_flag'=>secret_flag, 'gmsg'=>gmsg, 'res_rand'=>res_rand, 'res_msg'=>res_msg } else ght=bcdice.gotHelpMessage json_array={ 'ght'=>ght } end puts json_array.to_json </syntaxhighlight> [[Category:BCDice/TRPGツールからの呼び出し方]] {{DEFAULTSORT:おんせんるうむ}} 8e932075867590176b754b22ceb6cef68201ec8b BCDice/TRPGツールからの呼び出し方/どどんとふ 0 23 174 107 2020-08-24T21:24:38Z 0ヴ 9 wikitext text/x-wiki [[どどんとふ]]からの[[BCDice]]の呼び出し方。このページでは、Rubyで書かれたどどんとふのサーバのダイス関連の処理を扱う。[https://github.com/torgtaitai/DodontoF/tree/d3e4cc374885986efc761cfabbb19e4b35e815e0 v1.49.04.01]のソースコードを参考にしている == 各ファイルの役割 == どどんとふのサーバでは、ダイスボットとの通信の処理は以下のファイルに記述されている。 * [https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb src_ruby/dodontof/dice_adapter.rb]:BCDiceとのアダプタ * [https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/diceBotInfos.rb src_ruby/diceBotInfos.rb]:ダイスボットの情報を取得する処理 * [https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb DodontoFServer.rb]:サーバ本体 == src_ruby/dodontof/dice_adapter.rb:BCDiceとのアダプタ == https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb ダイスロールと関係していることがすぐに分かるファイル名だが、実は大部分は独自の表からの情報の読み出しやファイル管理の処理となっている。 === L7-L10:<code>DiceAdapter#initialize</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L7-L10 アダプタを初期化する。 * <code>@dir</code>:部屋固有のデータ保存ディレクトリが設定される。詳細は「[[#L164-L185:@dice_adapter の初期化]]」で解説する。 * <code>@diceBotTablePrefix</code>:必ず <code>'diceBotTable_'</code> が設定される。 <syntaxhighlight lang="ruby"> def initialize(dir, prefix) @logger = DodontoF::Logger.instance @dir = dir @diceBotTablePrefix = prefix end </syntaxhighlight> === L13-L34:<code>DiceAdapter#rollDice</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L13-L34 ダイスロールを行う。メッセージ、ゲームシステム、出目を返すかが指定できる。結果のメッセージ、シークレットダイスかどうか、出目が返る。結果のメッセージの <code>'>'</code> は <code>'→'</code> に置換され、末尾の改行コードは削除される。 <syntaxhighlight lang="ruby"> def rollDice(params) require 'cgiDiceBot.rb' message = params['message'] gameType = params['gameType'] isNeedResult = params['isNeedResult'] @logger.debug(message, 'rollDice message') @logger.debug(gameType, 'rollDice gameType') bot = CgiDiceBot.new result, randResults = bot.roll(message, gameType, @dir, @diceBotTablePrefix, isNeedResult) result.gsub!(/>/, '→') result.sub!(/\r?\n?\Z/m, '') @logger.debug(result, 'rollDice result') @logger.debug(randResults, 'rollDice randResults') return result, bot.isSecret, randResults end </syntaxhighlight> === L36-L45:<code>DiceAdapter#getGameCommandInfos</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L36-L45 独自の表について、ゲームタイプ(ゲームの識別子)および含まれるコマンドの情報を返す。<code>CgiDiceBot#getGameCommandInfos</code> を経由して <code>TableFileData#getGameCommandInfos</code> を呼び出している。 <syntaxhighlight lang="ruby"> def getGameCommandInfos require 'cgiDiceBot.rb' bot = CgiDiceBot.new @logger.debug(@dir, 'dir') commandInfos = bot.getGameCommandInfos(@dir, @diceBotTablePrefix) @logger.debug(commandInfos, "getGameCommandInfos End commandInfos") return commandInfos end </syntaxhighlight> === L47-L63:<code>DiceAdapter#getBotTableInfosFromDir</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L47-L63 独自の表についての情報を取得する。<code>getGameCommandInfos</code> と似ているが、こちらの方が返される情報が詳しい? <syntaxhighlight lang="ruby"> def getBotTableInfosFromDir @logger.debug(@dir, 'getBotTableInfosFromDir dir') require 'TableFileData' isLoadCommonTable = false tableFileData = TableFileData.new( isLoadCommonTable ) tableFileData.setDir(@dir, @diceBotTablePrefix) tableInfos = tableFileData.getAllTableInfo @logger.debug(tableInfos, "getBotTableInfosFromDir tableInfos") tableInfos.sort!{|a, b| a["command"].to_i <=> b["command"].to_i} @logger.debug(tableInfos, 'getBotTableInfosFromDir result tableInfos') return tableInfos end </syntaxhighlight> === L65-L84:<code>DiceAdapter#addBotTableMain</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L65-L84 独自の表のファイルを保存する。 <syntaxhighlight lang="ruby"> def addBotTableMain(params) @logger.debug("addBotTableMain Begin") DodontoF::Utils.makeDir(@dir) require 'TableFileData' resultText = 'OK' begin creator = TableFileCreator.new(@dir, @diceBotTablePrefix, params) creator.execute rescue Exception => e @logger.exception(e) resultText = getLanguageKey( e.to_s ) end @logger.debug(resultText, "addBotTableMain End resultText") return resultText end </syntaxhighlight> === L86-L103:<code>DiceAdapter#changeBotTableMain</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L86-L103 独自の表のファイルを更新する。 <syntaxhighlight lang="ruby"> def changeBotTableMain(params) @logger.debug("changeBotTableMain Begin") require 'TableFileData' resultText = 'OK' begin creator = TableFileEditer.new(@dir, @diceBotTablePrefix, params) creator.execute rescue Exception => e @logger.exception(e) resultText = getLanguageKey( e.to_s ) end @logger.debug(resultText, "changeBotTableMain End resultText") return resultText end </syntaxhighlight> === L105-L135:<code>DiceAdapter#removeBotTableMain</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L86-L103 独自の表のファイルを削除する。 <syntaxhighlight lang="ruby"> def removeBotTableMain(params) @logger.debug("removeBotTableMain Begin") command = params["command"] require 'TableFileData' isLoadCommonTable = false tableFileData = TableFileData.new( isLoadCommonTable ) tableFileData.setDir(@dir, @diceBotTablePrefix) tableInfos = tableFileData.getAllTableInfo tableInfo = tableInfos.find{|i| i["command"] == command} @logger.debug(tableInfo, "tableInfo") return if( tableInfo.nil? ) fileName = tableInfo["fileName"] @logger.debug(fileName, "fileName") return if( fileName.nil? ) @logger.debug("isFile exist?") return unless( File.exist?(fileName) ) begin File.delete(fileName) rescue Exception => e @logger.exception(e) end @logger.debug("removeBotTableMain End") end </syntaxhighlight> == src_ruby/diceBotInfos.rb:ダイスボットの情報を取得する処理 == https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/diceBotInfos.rb === L69-L102:<code>DiceBotInfos.get</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/diceBotInfos.rb#L69-L102 <syntaxhighlight lang="ruby"> # ダイスボットの情報の一覧を取得する # @param [Array<String>] orderedGameNames 順序付けられたゲーム名の配列 # @param [Boolean] showAllDiceBots すべてのダイスボットを表示するか # @return [Array<Hash>] def self.get(orderedGameNames, showAllDiceBots) diceBots = DiceBotLoader.collectDiceBots # ゲーム名 => ダイスボットの対応を作る diceBotFor = Hash[ diceBots.map { |diceBot| [diceBot.gameName, diceBot] } ] toDiceBot = lambda { |gameName| diceBotFor[gameName] } orderedEnabledDiceBots = orderedGameNames. map(&toDiceBot). # ゲーム名が誤記されていた場合nilになるので除く compact orderedDiceBots = if showAllDiceBots disabledGameNames = diceBotFor.keys - orderedGameNames orderedDisabledDiceBots = disabledGameNames. sort. map(&toDiceBot) # 一覧に記載されていたゲーム→記載されていなかったゲームの順 orderedEnabledDiceBots + orderedDisabledDiceBots else orderedEnabledDiceBots end # 指定なし→各ゲーム→基本の順で返す [NONE_DICE_BOT_INFO] + orderedDiceBots.map(&:info) + [BASE_DICE_BOT_INFO] end </syntaxhighlight> === L104-150:<code>DiceBotInfos.withTableCommands</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/diceBotInfos.rb#L104-150 <syntaxhighlight lang="ruby"> # テーブルのコマンドも加えたダイスボットの情報の一覧を取得する # @param [Array<String>] orderedGameNames 順序付けられたゲーム名の配列 # @param [Boolean] showAllDiceBots すべてのダイスボットを表示するか # @param [Array<Hash>] commandInfos テーブルのコマンドの情報の配列 # @return [Array<Hash>] # # このメソッドは、ダイスボットから返された情報を破壊しない。 def self.withTableCommands(orderedGameNames, showAllDiceBots, commandInfos) diceBotInfos = self.get(orderedGameNames, showAllDiceBots) # ゲームタイプ => ダイスボット情報のインデックスの対応を作る diceBotInfoIndexFor = Hash[ diceBotInfos.each_with_index.map { |info, i| [info[KEY_GAME_TYPE], i] } ] allGameTypes = diceBotInfoIndexFor.keys # ゲームタイプ => 追加するコマンドの一覧の対応を作る commandsToAdd = commandInfos.reduce({}) { |acc, commandInfo| gameType = commandInfo[KEY_GAME_TYPE] command = commandInfo[KEY_COMMAND] # ゲームタイプ未指定ならすべてのゲームタイプに追加する targetGameTypes = gameType.empty? ? allGameTypes : [gameType] targetGameTypes.each do |targetGameType| acc[targetGameType] ||= [] acc[targetGameType] << command end acc } commandsToAdd.each do |gameType, commands| diceBotInfoIndex = diceBotInfoIndexFor[gameType] next unless diceBotInfoIndex originalInfo = diceBotInfos[diceBotInfoIndex] # ダイスボットから返された情報を破壊しないようにして更新する diceBotInfos[diceBotInfoIndex] = originalInfo.merge({ KEY_PREFIXS => originalInfo[KEY_PREFIXS] + commands }) end diceBotInfos end </syntaxhighlight> == DodontoFServer.rb:サーバ本体 == https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb === L164-L185:<code>@dice_adapter</code> の初期化 === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L164-L185 <syntaxhighlight lang="ruby"> def initialize(saveDirInfo, cgiParams) @cgiParams = cgiParams @saveDirInfo = saveDirInfo @logger = DodontoF::Logger.instance @cgi = nil @jsonpCallBack = nil @isWebIf = false @isRecordEmpty = false initSaveFiles(getRequestData('room')) @dice_adapter = DodontoF::DiceAdapter.new(getDiceBotExtraTableDirName, 'diceBotTable_') @fullBackupFileBaseName = "DodontoFFullBackup" @allSaveDataFileExt = '.tar.gz' @defaultAllSaveData = 'default.sav' @defaultChatPallete = 'default.cpd' @card = nil end </syntaxhighlight> <code>getDiceBotExtraTableDirName</code>([https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3727-L3729 L3727-L3729])では、<code>getRoomLocalSpaceDirName</code>([https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3262-L3265 L3262-L3265])、<code>getRoomLocalSpaceDirNameByRoomNo</code>([https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3267-L3273 L3267-L3273])を経由して、<code>$imageUploadDir</code> の中の部屋固有のディレクトリを返す。 === L1193-L1210:<code>DodontoFServer#getWebIfServerInfo</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L1193-L1210 Webインターフェースのサーバ情報を返すコマンド。<code>getDiceBotInfos</code> でダイスボットの情報を取得する。 <syntaxhighlight lang="ruby"> def getWebIfServerInfo() jsonData = { "maxRoom" => ($saveDataMaxCount - 1), 'isNeedCreatePassword' => (not $createPlayRoomPassword.empty?), 'result' => 'OK', } if( getWebIfRequestBoolean("card", false) ) cardInfos = getCardsInfo.collectCardTypeAndTypeName($cardOrder) jsonData["cardInfos"] = cardInfos end if( getWebIfRequestBoolean("dice", false) ) jsonData['diceBotInfos'] = getDiceBotInfos() end return jsonData end </syntaxhighlight> === L2090:<code>DodontoFServer#getLoginInfo</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2090 ダイスボット情報の取得を行う。 <syntaxhighlight lang="ruby"> diceBotInfos = getDiceBotInfos() </syntaxhighlight> === L2266-L2280:<code>DodontoFServer#getDiceBotInfos</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2266-L2280 ダイスボット情報取得処理の実装。部屋に入っているかどうかで、テーブルのコマンドも含めた情報を返すかどうかを決定している。 <syntaxhighlight lang="ruby"> def getDiceBotInfos @logger.debug("getDiceBotInfos() Begin") require 'diceBotInfos' orderedGameNames = $diceBotOrder.split("\n") if @saveDirInfo.getSaveDataDirIndex != -1 DiceBotInfos.withTableCommands(orderedGameNames, $isDisplayAllDice, @dice_adapter.getGameCommandInfos) else DiceBotInfos.get(orderedGameNames, $isDisplayAllDice) end end </syntaxhighlight> === L2542-2556:<code>DodontoFServer#save</code>, <code>getDiceTableData</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2542-2556 部屋のデータの保存時に、独自の表についての情報を取得する。 <syntaxhighlight lang="ruby"> def save() isAddPlayRoomInfo = true extension = @@saveFileExtension addInfos = {} addInfos[$diceBotTableSaveKey] = getDiceTableData() saveSelectFiles($saveFiles.keys, extension, isAddPlayRoomInfo, addInfos) end def getDiceTableData() tableInfos = @dice_adapter.getBotTableInfosFromDir tableInfos.each{|i| i.delete('fileName') } return tableInfos end </syntaxhighlight> === L2806-L2817:<code>DodontoFServer#getBotTableInfos</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2806-L2817 独自の表についての情報を取得する。 <syntaxhighlight lang="ruby"> def getBotTableInfos() @logger.debug("getBotTableInfos Begin") result = { "resultText"=> "OK", } result["tableInfos"] = @dice_adapter.getBotTableInfosFromDir @logger.debug(result, "result") @logger.debug("getBotTableInfos End") return result end </syntaxhighlight> === L2819-L2835:<code>DodontoFServer#addBotTable</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2819-L2835 独自の表を追加する。 <syntaxhighlight lang="ruby"> def addBotTable() result = {} params = getParamsFromRequestData() result['resultText'] = @dice_adapter.addBotTableMain(params) if( result['resultText'] != "OK" ) return result end @logger.debug("addBotTableMain called") result = getBotTableInfos() @logger.debug(result, "addBotTable result") return result end </syntaxhighlight> === L2837-L2849:<code>DodontoFServer#changeBotTable</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2837-L2849 独自の表を変更する。 <syntaxhighlight lang="ruby"> def changeBotTable() params = getParamsFromRequestData() result = {} result['resultText'] = @dice_adapter.changeBotTableMain(params) if( result['resultText'] != "OK" ) return result end result = getBotTableInfos() return result end </syntaxhighlight> === L2851-L2855:<code>DodontoFServer#removeBotTable</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2851-L2855 独自の表を削除する。 <syntaxhighlight lang="ruby"> def removeBotTable() params = getParamsFromRequestData() @dice_adapter.removeBotTableMain(params) return getBotTableInfos() end </syntaxhighlight> === L3458-L3459:<code>DodontoFServer#loadSaveFileDataFilterByTargets</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3458-L3459 セーブデータの部分読み込み処理の一部。独自の表を読み込む。 <syntaxhighlight lang="ruby"> when "diceBotTable" loadDiceBotTable(jsonData) </syntaxhighlight> === L3511-L3531:<code>DodontoFServer#loadDiceBotTable</code>, <code>DodontoFServer#getDiceBotTableString</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3511-L3531 独自の表を読み込む。 <syntaxhighlight lang="ruby"> def loadDiceBotTable(jsonData) data = jsonData[$diceBotTableSaveKey] return if( data.nil? ) data.each do |info| info['table'] = getDiceBotTableString(info['table']) @dice_adapter.addBotTableMain(info) end end def getDiceBotTableString(table) lines = [] table.each do |line| lines << line.join(":") end return lines.join("\n") end </syntaxhighlight> === L3632-L3657:<code>DodontoFServer#sendDiceBotChatMessage</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3632-L3657 BCDiceにコマンドを送る処理。<code>回数 コマンド</code> という形で送信回数が指定されていた場合は、指定された回数だけコマンドをBCDiceに送る。 <syntaxhighlight lang="ruby"> def sendDiceBotChatMessage @logger.debug('sendDiceBotChatMessage') params = getParamsFromRequestData() repeatCount = getDiceBotRepeatCount(params) results = [] repeatCount.times do |i| paramsClone = params.clone paramsClone['message'] += " \##{ i + 1 }" if( repeatCount > 1 ) result = sendDiceBotChatMessageOnece( paramsClone ) @logger.debug(result, "sendDiceBotChatMessageOnece result") next if( result.nil? ) results << result end @logger.debug(results, "sendDiceBotChatMessage results") return results end </syntaxhighlight> === L3659-L3669:<code>DodontoFServer#getDiceBotRepeatCount</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3659-L3669 コマンド送信回数を1〜20回に制限する。最近のRubyでは <code>(params['repeatCount'] || 1).clamp(1, 20)</code> と簡潔に書ける。 <syntaxhighlight lang="ruby"> def getDiceBotRepeatCount(params) repeatCountLimit = 20 repeatCount = params['repeatCount'] repeatCount ||= 1 repeatCount = 1 if( repeatCount < 1 ) repeatCount = repeatCountLimit if( repeatCount > repeatCountLimit ) return repeatCount end </syntaxhighlight> === L3672-L3709:<code>DodontoFServer#sendDiceBotChatMessageOnece</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3672-L3709 BCDiceに1回分(おそらく <code>Onece</code> は <code>once</code> のスペルミス)のコマンドを送る処理。<code>getRollDiceResult</code> でダイスロールした結果を取得する。<code>sendChatMessageByChatData</code>([https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3817-3839 L3817-3839])で、その結果を含むメッセージを送信する。 <syntaxhighlight lang="ruby"> def sendDiceBotChatMessageOnece(params) rolledMessage, isSecret, secretMessage = getRollDiceResult( params ) senderName = params['name'] unless /\t/ === senderName state = params['state'] senderName += ("\t" + state) unless( state.empty? ) end chatData = { "senderName" => senderName, "message" => rolledMessage, "color" => params['color'], "uniqueId" => '0', "channel" => params['channel'] } sendto = params['sendto'] unless( sendto.nil? ) chatData['sendto'] = sendto chatData['sendtoName'] = sendtoName end @logger.debug(chatData, 'sendDiceBotChatMessageOnece chatData') sendChatMessageByChatData(chatData) result = nil if( isSecret ) params['isSecret'] = isSecret params['message'] = secretMessage result = params end return result end </syntaxhighlight> === L3672-L3725:<code>DodontoFServer#getRollDiceResult</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3672-L3709 BCDiceでダイスを振る。シークレットダイスかどうかも考慮してメッセージを加工し、返す。 <syntaxhighlight lang="ruby"> def getRollDiceResult( params ) params['originalMessage'] = params['message'] rollResult, isSecret, randResults = @dice_adapter.rollDice(params) secretMessage = "" if( isSecret ) secretMessage = params['message'] + rollResult else params['message'] += rollResult end rolledMessage = getRolledMessage(params, isSecret, randResults) return rolledMessage, isSecret, secretMessage end </syntaxhighlight> === L3732-L3762:<code>DodontoFServer#getRolledMessage</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3732-L3709 ダイスロールの結果を入力として、どどんとふクライアントでの表示に必要な情報を付加する。シークレットダイスの場合に結果を隠すことと、「!」の数でサイコロを強調できるようにすることが目的のようだ。 <syntaxhighlight lang="ruby"> def getRolledMessage(params, isSecret, randResults) @logger.debug("getRolledMessage Begin") @logger.debug(isSecret, "isSecret") @logger.debug(randResults, "randResults") if( isSecret ) params['message'] = getLanguageKey('secretDice') randResults = randResults.collect{|value, max| [0, 0] } end message = params['message'] if( randResults.nil? ) @logger.debug("randResults is nil") return message end data = { "chatMessage" => message, "randResults" => randResults, "uniqueId" => params['uniqueId'], "power" => getDiceBotPower(params), } text = "###CutInCommand:rollVisualDice###" + getJsonString(data) @logger.debug(text, "getRolledMessage End text") return text end </syntaxhighlight> [[Category:BCDice/TRPGツールからの呼び出し方]] {{DEFAULTSORT:ととんとふ}} fe3f07e0de7619a961cdc1a183854f44dacc71f8 189 174 2020-08-24T22:43:15Z 118.10.82.175 0 [[Special:Contributions/0ヴ|0ヴ]] ([[User talk:0ヴ|トーク]]) による版 174 を取り消し wikitext text/x-wiki [[どどんとふ]]からの[[BCDice]]の呼び出し方。このページでは、Rubyで書かれたどどんとふのサーバのダイス関連の処理を扱う。[https://github.com/torgtaitai/DodontoF/tree/d3e4cc374885986efc761cfabbb19e4b35e815e0 v1.49.04.01]のソースコードを参考にしている。 == 各ファイルの役割 == どどんとふのサーバでは、ダイスボットとの通信の処理は以下のファイルに記述されている。 * [https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb src_ruby/dodontof/dice_adapter.rb]:BCDiceとのアダプタ * [https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/diceBotInfos.rb src_ruby/diceBotInfos.rb]:ダイスボットの情報を取得する処理 * [https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb DodontoFServer.rb]:サーバ本体 == src_ruby/dodontof/dice_adapter.rb:BCDiceとのアダプタ == https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb ダイスロールと関係していることがすぐに分かるファイル名だが、実は大部分は独自の表からの情報の読み出しやファイル管理の処理となっている。 === L7-L10:<code>DiceAdapter#initialize</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L7-L10 アダプタを初期化する。 * <code>@dir</code>:部屋固有のデータ保存ディレクトリが設定される。詳細は「[[#L164-L185:@dice_adapter の初期化]]」で解説する。 * <code>@diceBotTablePrefix</code>:必ず <code>'diceBotTable_'</code> が設定される。 <syntaxhighlight lang="ruby"> def initialize(dir, prefix) @logger = DodontoF::Logger.instance @dir = dir @diceBotTablePrefix = prefix end </syntaxhighlight> === L13-L34:<code>DiceAdapter#rollDice</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L13-L34 ダイスロールを行う。メッセージ、ゲームシステム、出目を返すかが指定できる。結果のメッセージ、シークレットダイスかどうか、出目が返る。結果のメッセージの <code>'>'</code> は <code>'→'</code> に置換され、末尾の改行コードは削除される。 <syntaxhighlight lang="ruby"> def rollDice(params) require 'cgiDiceBot.rb' message = params['message'] gameType = params['gameType'] isNeedResult = params['isNeedResult'] @logger.debug(message, 'rollDice message') @logger.debug(gameType, 'rollDice gameType') bot = CgiDiceBot.new result, randResults = bot.roll(message, gameType, @dir, @diceBotTablePrefix, isNeedResult) result.gsub!(/>/, '→') result.sub!(/\r?\n?\Z/m, '') @logger.debug(result, 'rollDice result') @logger.debug(randResults, 'rollDice randResults') return result, bot.isSecret, randResults end </syntaxhighlight> === L36-L45:<code>DiceAdapter#getGameCommandInfos</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L36-L45 独自の表について、ゲームタイプ(ゲームの識別子)および含まれるコマンドの情報を返す。<code>CgiDiceBot#getGameCommandInfos</code> を経由して <code>TableFileData#getGameCommandInfos</code> を呼び出している。 <syntaxhighlight lang="ruby"> def getGameCommandInfos require 'cgiDiceBot.rb' bot = CgiDiceBot.new @logger.debug(@dir, 'dir') commandInfos = bot.getGameCommandInfos(@dir, @diceBotTablePrefix) @logger.debug(commandInfos, "getGameCommandInfos End commandInfos") return commandInfos end </syntaxhighlight> === L47-L63:<code>DiceAdapter#getBotTableInfosFromDir</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L47-L63 独自の表についての情報を取得する。<code>getGameCommandInfos</code> と似ているが、こちらの方が返される情報が詳しい? <syntaxhighlight lang="ruby"> def getBotTableInfosFromDir @logger.debug(@dir, 'getBotTableInfosFromDir dir') require 'TableFileData' isLoadCommonTable = false tableFileData = TableFileData.new( isLoadCommonTable ) tableFileData.setDir(@dir, @diceBotTablePrefix) tableInfos = tableFileData.getAllTableInfo @logger.debug(tableInfos, "getBotTableInfosFromDir tableInfos") tableInfos.sort!{|a, b| a["command"].to_i <=> b["command"].to_i} @logger.debug(tableInfos, 'getBotTableInfosFromDir result tableInfos') return tableInfos end </syntaxhighlight> === L65-L84:<code>DiceAdapter#addBotTableMain</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L65-L84 独自の表のファイルを保存する。 <syntaxhighlight lang="ruby"> def addBotTableMain(params) @logger.debug("addBotTableMain Begin") DodontoF::Utils.makeDir(@dir) require 'TableFileData' resultText = 'OK' begin creator = TableFileCreator.new(@dir, @diceBotTablePrefix, params) creator.execute rescue Exception => e @logger.exception(e) resultText = getLanguageKey( e.to_s ) end @logger.debug(resultText, "addBotTableMain End resultText") return resultText end </syntaxhighlight> === L86-L103:<code>DiceAdapter#changeBotTableMain</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L86-L103 独自の表のファイルを更新する。 <syntaxhighlight lang="ruby"> def changeBotTableMain(params) @logger.debug("changeBotTableMain Begin") require 'TableFileData' resultText = 'OK' begin creator = TableFileEditer.new(@dir, @diceBotTablePrefix, params) creator.execute rescue Exception => e @logger.exception(e) resultText = getLanguageKey( e.to_s ) end @logger.debug(resultText, "changeBotTableMain End resultText") return resultText end </syntaxhighlight> === L105-L135:<code>DiceAdapter#removeBotTableMain</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L86-L103 独自の表のファイルを削除する。 <syntaxhighlight lang="ruby"> def removeBotTableMain(params) @logger.debug("removeBotTableMain Begin") command = params["command"] require 'TableFileData' isLoadCommonTable = false tableFileData = TableFileData.new( isLoadCommonTable ) tableFileData.setDir(@dir, @diceBotTablePrefix) tableInfos = tableFileData.getAllTableInfo tableInfo = tableInfos.find{|i| i["command"] == command} @logger.debug(tableInfo, "tableInfo") return if( tableInfo.nil? ) fileName = tableInfo["fileName"] @logger.debug(fileName, "fileName") return if( fileName.nil? ) @logger.debug("isFile exist?") return unless( File.exist?(fileName) ) begin File.delete(fileName) rescue Exception => e @logger.exception(e) end @logger.debug("removeBotTableMain End") end </syntaxhighlight> == src_ruby/diceBotInfos.rb:ダイスボットの情報を取得する処理 == https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/diceBotInfos.rb === L69-L102:<code>DiceBotInfos.get</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/diceBotInfos.rb#L69-L102 <syntaxhighlight lang="ruby"> # ダイスボットの情報の一覧を取得する # @param [Array<String>] orderedGameNames 順序付けられたゲーム名の配列 # @param [Boolean] showAllDiceBots すべてのダイスボットを表示するか # @return [Array<Hash>] def self.get(orderedGameNames, showAllDiceBots) diceBots = DiceBotLoader.collectDiceBots # ゲーム名 => ダイスボットの対応を作る diceBotFor = Hash[ diceBots.map { |diceBot| [diceBot.gameName, diceBot] } ] toDiceBot = lambda { |gameName| diceBotFor[gameName] } orderedEnabledDiceBots = orderedGameNames. map(&toDiceBot). # ゲーム名が誤記されていた場合nilになるので除く compact orderedDiceBots = if showAllDiceBots disabledGameNames = diceBotFor.keys - orderedGameNames orderedDisabledDiceBots = disabledGameNames. sort. map(&toDiceBot) # 一覧に記載されていたゲーム→記載されていなかったゲームの順 orderedEnabledDiceBots + orderedDisabledDiceBots else orderedEnabledDiceBots end # 指定なし→各ゲーム→基本の順で返す [NONE_DICE_BOT_INFO] + orderedDiceBots.map(&:info) + [BASE_DICE_BOT_INFO] end </syntaxhighlight> === L104-150:<code>DiceBotInfos.withTableCommands</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/diceBotInfos.rb#L104-150 <syntaxhighlight lang="ruby"> # テーブルのコマンドも加えたダイスボットの情報の一覧を取得する # @param [Array<String>] orderedGameNames 順序付けられたゲーム名の配列 # @param [Boolean] showAllDiceBots すべてのダイスボットを表示するか # @param [Array<Hash>] commandInfos テーブルのコマンドの情報の配列 # @return [Array<Hash>] # # このメソッドは、ダイスボットから返された情報を破壊しない。 def self.withTableCommands(orderedGameNames, showAllDiceBots, commandInfos) diceBotInfos = self.get(orderedGameNames, showAllDiceBots) # ゲームタイプ => ダイスボット情報のインデックスの対応を作る diceBotInfoIndexFor = Hash[ diceBotInfos.each_with_index.map { |info, i| [info[KEY_GAME_TYPE], i] } ] allGameTypes = diceBotInfoIndexFor.keys # ゲームタイプ => 追加するコマンドの一覧の対応を作る commandsToAdd = commandInfos.reduce({}) { |acc, commandInfo| gameType = commandInfo[KEY_GAME_TYPE] command = commandInfo[KEY_COMMAND] # ゲームタイプ未指定ならすべてのゲームタイプに追加する targetGameTypes = gameType.empty? ? allGameTypes : [gameType] targetGameTypes.each do |targetGameType| acc[targetGameType] ||= [] acc[targetGameType] << command end acc } commandsToAdd.each do |gameType, commands| diceBotInfoIndex = diceBotInfoIndexFor[gameType] next unless diceBotInfoIndex originalInfo = diceBotInfos[diceBotInfoIndex] # ダイスボットから返された情報を破壊しないようにして更新する diceBotInfos[diceBotInfoIndex] = originalInfo.merge({ KEY_PREFIXS => originalInfo[KEY_PREFIXS] + commands }) end diceBotInfos end </syntaxhighlight> == DodontoFServer.rb:サーバ本体 == https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb === L164-L185:<code>@dice_adapter</code> の初期化 === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L164-L185 <syntaxhighlight lang="ruby"> def initialize(saveDirInfo, cgiParams) @cgiParams = cgiParams @saveDirInfo = saveDirInfo @logger = DodontoF::Logger.instance @cgi = nil @jsonpCallBack = nil @isWebIf = false @isRecordEmpty = false initSaveFiles(getRequestData('room')) @dice_adapter = DodontoF::DiceAdapter.new(getDiceBotExtraTableDirName, 'diceBotTable_') @fullBackupFileBaseName = "DodontoFFullBackup" @allSaveDataFileExt = '.tar.gz' @defaultAllSaveData = 'default.sav' @defaultChatPallete = 'default.cpd' @card = nil end </syntaxhighlight> <code>getDiceBotExtraTableDirName</code>([https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3727-L3729 L3727-L3729])では、<code>getRoomLocalSpaceDirName</code>([https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3262-L3265 L3262-L3265])、<code>getRoomLocalSpaceDirNameByRoomNo</code>([https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3267-L3273 L3267-L3273])を経由して、<code>$imageUploadDir</code> の中の部屋固有のディレクトリを返す。 === L1193-L1210:<code>DodontoFServer#getWebIfServerInfo</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L1193-L1210 Webインターフェースのサーバ情報を返すコマンド。<code>getDiceBotInfos</code> でダイスボットの情報を取得する。 <syntaxhighlight lang="ruby"> def getWebIfServerInfo() jsonData = { "maxRoom" => ($saveDataMaxCount - 1), 'isNeedCreatePassword' => (not $createPlayRoomPassword.empty?), 'result' => 'OK', } if( getWebIfRequestBoolean("card", false) ) cardInfos = getCardsInfo.collectCardTypeAndTypeName($cardOrder) jsonData["cardInfos"] = cardInfos end if( getWebIfRequestBoolean("dice", false) ) jsonData['diceBotInfos'] = getDiceBotInfos() end return jsonData end </syntaxhighlight> === L2090:<code>DodontoFServer#getLoginInfo</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2090 ダイスボット情報の取得を行う。 <syntaxhighlight lang="ruby"> diceBotInfos = getDiceBotInfos() </syntaxhighlight> === L2266-L2280:<code>DodontoFServer#getDiceBotInfos</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2266-L2280 ダイスボット情報取得処理の実装。部屋に入っているかどうかで、テーブルのコマンドも含めた情報を返すかどうかを決定している。 <syntaxhighlight lang="ruby"> def getDiceBotInfos @logger.debug("getDiceBotInfos() Begin") require 'diceBotInfos' orderedGameNames = $diceBotOrder.split("\n") if @saveDirInfo.getSaveDataDirIndex != -1 DiceBotInfos.withTableCommands(orderedGameNames, $isDisplayAllDice, @dice_adapter.getGameCommandInfos) else DiceBotInfos.get(orderedGameNames, $isDisplayAllDice) end end </syntaxhighlight> === L2542-2556:<code>DodontoFServer#save</code>, <code>getDiceTableData</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2542-2556 部屋のデータの保存時に、独自の表についての情報を取得する。 <syntaxhighlight lang="ruby"> def save() isAddPlayRoomInfo = true extension = @@saveFileExtension addInfos = {} addInfos[$diceBotTableSaveKey] = getDiceTableData() saveSelectFiles($saveFiles.keys, extension, isAddPlayRoomInfo, addInfos) end def getDiceTableData() tableInfos = @dice_adapter.getBotTableInfosFromDir tableInfos.each{|i| i.delete('fileName') } return tableInfos end </syntaxhighlight> === L2806-L2817:<code>DodontoFServer#getBotTableInfos</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2806-L2817 独自の表についての情報を取得する。 <syntaxhighlight lang="ruby"> def getBotTableInfos() @logger.debug("getBotTableInfos Begin") result = { "resultText"=> "OK", } result["tableInfos"] = @dice_adapter.getBotTableInfosFromDir @logger.debug(result, "result") @logger.debug("getBotTableInfos End") return result end </syntaxhighlight> === L2819-L2835:<code>DodontoFServer#addBotTable</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2819-L2835 独自の表を追加する。 <syntaxhighlight lang="ruby"> def addBotTable() result = {} params = getParamsFromRequestData() result['resultText'] = @dice_adapter.addBotTableMain(params) if( result['resultText'] != "OK" ) return result end @logger.debug("addBotTableMain called") result = getBotTableInfos() @logger.debug(result, "addBotTable result") return result end </syntaxhighlight> === L2837-L2849:<code>DodontoFServer#changeBotTable</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2837-L2849 独自の表を変更する。 <syntaxhighlight lang="ruby"> def changeBotTable() params = getParamsFromRequestData() result = {} result['resultText'] = @dice_adapter.changeBotTableMain(params) if( result['resultText'] != "OK" ) return result end result = getBotTableInfos() return result end </syntaxhighlight> === L2851-L2855:<code>DodontoFServer#removeBotTable</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2851-L2855 独自の表を削除する。 <syntaxhighlight lang="ruby"> def removeBotTable() params = getParamsFromRequestData() @dice_adapter.removeBotTableMain(params) return getBotTableInfos() end </syntaxhighlight> === L3458-L3459:<code>DodontoFServer#loadSaveFileDataFilterByTargets</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3458-L3459 セーブデータの部分読み込み処理の一部。独自の表を読み込む。 <syntaxhighlight lang="ruby"> when "diceBotTable" loadDiceBotTable(jsonData) </syntaxhighlight> === L3511-L3531:<code>DodontoFServer#loadDiceBotTable</code>, <code>DodontoFServer#getDiceBotTableString</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3511-L3531 独自の表を読み込む。 <syntaxhighlight lang="ruby"> def loadDiceBotTable(jsonData) data = jsonData[$diceBotTableSaveKey] return if( data.nil? ) data.each do |info| info['table'] = getDiceBotTableString(info['table']) @dice_adapter.addBotTableMain(info) end end def getDiceBotTableString(table) lines = [] table.each do |line| lines << line.join(":") end return lines.join("\n") end </syntaxhighlight> === L3632-L3657:<code>DodontoFServer#sendDiceBotChatMessage</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3632-L3657 BCDiceにコマンドを送る処理。<code>回数 コマンド</code> という形で送信回数が指定されていた場合は、指定された回数だけコマンドをBCDiceに送る。 <syntaxhighlight lang="ruby"> def sendDiceBotChatMessage @logger.debug('sendDiceBotChatMessage') params = getParamsFromRequestData() repeatCount = getDiceBotRepeatCount(params) results = [] repeatCount.times do |i| paramsClone = params.clone paramsClone['message'] += " \##{ i + 1 }" if( repeatCount > 1 ) result = sendDiceBotChatMessageOnece( paramsClone ) @logger.debug(result, "sendDiceBotChatMessageOnece result") next if( result.nil? ) results << result end @logger.debug(results, "sendDiceBotChatMessage results") return results end </syntaxhighlight> === L3659-L3669:<code>DodontoFServer#getDiceBotRepeatCount</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3659-L3669 コマンド送信回数を1〜20回に制限する。最近のRubyでは <code>(params['repeatCount'] || 1).clamp(1, 20)</code> と簡潔に書ける。 <syntaxhighlight lang="ruby"> def getDiceBotRepeatCount(params) repeatCountLimit = 20 repeatCount = params['repeatCount'] repeatCount ||= 1 repeatCount = 1 if( repeatCount < 1 ) repeatCount = repeatCountLimit if( repeatCount > repeatCountLimit ) return repeatCount end </syntaxhighlight> === L3672-L3709:<code>DodontoFServer#sendDiceBotChatMessageOnece</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3672-L3709 BCDiceに1回分(おそらく <code>Onece</code> は <code>once</code> のスペルミス)のコマンドを送る処理。<code>getRollDiceResult</code> でダイスロールした結果を取得する。<code>sendChatMessageByChatData</code>([https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3817-3839 L3817-3839])で、その結果を含むメッセージを送信する。 <syntaxhighlight lang="ruby"> def sendDiceBotChatMessageOnece(params) rolledMessage, isSecret, secretMessage = getRollDiceResult( params ) senderName = params['name'] unless /\t/ === senderName state = params['state'] senderName += ("\t" + state) unless( state.empty? ) end chatData = { "senderName" => senderName, "message" => rolledMessage, "color" => params['color'], "uniqueId" => '0', "channel" => params['channel'] } sendto = params['sendto'] unless( sendto.nil? ) chatData['sendto'] = sendto chatData['sendtoName'] = sendtoName end @logger.debug(chatData, 'sendDiceBotChatMessageOnece chatData') sendChatMessageByChatData(chatData) result = nil if( isSecret ) params['isSecret'] = isSecret params['message'] = secretMessage result = params end return result end </syntaxhighlight> === L3672-L3725:<code>DodontoFServer#getRollDiceResult</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3672-L3709 BCDiceでダイスを振る。シークレットダイスかどうかも考慮してメッセージを加工し、返す。 <syntaxhighlight lang="ruby"> def getRollDiceResult( params ) params['originalMessage'] = params['message'] rollResult, isSecret, randResults = @dice_adapter.rollDice(params) secretMessage = "" if( isSecret ) secretMessage = params['message'] + rollResult else params['message'] += rollResult end rolledMessage = getRolledMessage(params, isSecret, randResults) return rolledMessage, isSecret, secretMessage end </syntaxhighlight> === L3732-L3762:<code>DodontoFServer#getRolledMessage</code> === https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3732-L3709 ダイスロールの結果を入力として、どどんとふクライアントでの表示に必要な情報を付加する。シークレットダイスの場合に結果を隠すことと、「!」の数でサイコロを強調できるようにすることが目的のようだ。 <syntaxhighlight lang="ruby"> def getRolledMessage(params, isSecret, randResults) @logger.debug("getRolledMessage Begin") @logger.debug(isSecret, "isSecret") @logger.debug(randResults, "randResults") if( isSecret ) params['message'] = getLanguageKey('secretDice') randResults = randResults.collect{|value, max| [0, 0] } end message = params['message'] if( randResults.nil? ) @logger.debug("randResults is nil") return message end data = { "chatMessage" => message, "randResults" => randResults, "uniqueId" => params['uniqueId'], "power" => getDiceBotPower(params), } text = "###CutInCommand:rollVisualDice###" + getJsonString(data) @logger.debug(text, "getRolledMessage End text") return text end </syntaxhighlight> [[Category:BCDice/TRPGツールからの呼び出し方]] {{DEFAULTSORT:ととんとふ}} 5de9b82e89eea7a328b3c62e7996f55f3906f668 BCDice/TRPGツールからの呼び出し方/ダイスロールのみ利用する場合 0 49 175 116 2020-08-24T21:25:47Z 0ヴ 9 wikitext text/x-wiki [[BCDice]]のダイスロール機能のみを利用する場合の、[[Ruby]]プログラムからの呼び出し方をまとめる。 __TOC_ == BCDice関連ファイルを読み込む == BCDiceの機能を利用する前に、1回だけ関連ファイルを読み込む必要がある。BCDiceが配置されているディレクトリを読み込みパスに追加してから、関連ファイルを読み込む。 <syntaxhighlight lang="ruby"> # BCDiceが配置されているディレクトリを読み込みパスに追加する $LOAD_PATH.unshift('/path/to/BCDice/src') # BCDice関連ファイルを読み込む require 'diceBot/DiceBot' require 'diceBot/DiceBotLoader' require 'bcdiceCore' </syntaxhighlight> == ダイスロールを行う == BCDiceのダイスロール機能を呼び出すプログラムの概要を以下に示す。 <syntaxhighlight lang="ruby"> # ゲーム名(英数字。省略名でも可) # * 省略名の例:DX(DoubleCross)、SW20(SwordWorld2.0) game_title = 'DoubleCross' # コマンド command = '2DX+4@10' # 新しいBCDiceインスタンスを作る bcdice = BCDiceMaker.new.newBcDice # ゲームを指定する bcdice.setGameByTitle(game_title) # BCDiceに送るメッセージ(コマンド)を指定する bcdice.setMessage(command) # ダイスロールの結果(出目)を返すように設定する bcdice.setCollectRandResult(true) # ダイスロールを行い、結果を受け取る # * output:ダイスロールの結果(出目の合計など)を示すメッセージ # * 例:"2DX+4@10 : (2R10+4[10]) > 8[7,8]+4 > 12" # * secret:シークレットダイスならばtrue、そうでなければfalse output, secret = bcdice.dice_command # 出目の情報を受け取る # 2つの整数要素を持つ配列の配列として返ってくる # * 返り値の例:[[7, 10], [8, 10]](10面ダイスの7、10面ダイスの8) rolled_dice = bcdice.getRandResults </syntaxhighlight> == 利用できるダイスボットの一覧を取得する == <code>DiceBotLoader.collectDiceBots</code> を呼び出すと、利用可能なダイスボットの配列を取得することができる。これを利用して、利用できるダイスボットの一覧を作ることができる。 <syntaxhighlight lang="ruby"> # 利用できるダイスボットの配列 dicebots = DiceBotLoader.collectDiceBots # 特定のゲームを対象としないダイスボットも一覧に加える場合 # dicebots = DiceBotLoader.collectDiceBots + [DiceBot.new] # ゲーム識別子(英数字)の配列を作る game_types = dicebots.map(&:gameType) # ゲーム名(日本語)の配列を作る game_names = dicebots.map(&:gameName) </syntaxhighlight> 3e7b12ba637b78c4049d80e27ae89b6d47b77d5f 190 175 2020-08-24T22:44:17Z 118.10.82.175 0 [[Special:Contributions/0ヴ|0ヴ]] ([[User talk:0ヴ|トーク]]) による版 175 を取り消し wikitext text/x-wiki [[BCDice]]のダイスロール機能のみを利用する場合の、[[Ruby]]プログラムからの呼び出し方をまとめる。 __TOC__ == BCDice関連ファイルを読み込む == BCDiceの機能を利用する前に、1回だけ関連ファイルを読み込む必要がある。BCDiceが配置されているディレクトリを読み込みパスに追加してから、関連ファイルを読み込む。 <syntaxhighlight lang="ruby"> # BCDiceが配置されているディレクトリを読み込みパスに追加する $LOAD_PATH.unshift('/path/to/BCDice/src') # BCDice関連ファイルを読み込む require 'diceBot/DiceBot' require 'diceBot/DiceBotLoader' require 'bcdiceCore' </syntaxhighlight> == ダイスロールを行う == BCDiceのダイスロール機能を呼び出すプログラムの概要を以下に示す。 <syntaxhighlight lang="ruby"> # ゲーム名(英数字。省略名でも可) # * 省略名の例:DX(DoubleCross)、SW20(SwordWorld2.0) game_title = 'DoubleCross' # コマンド command = '2DX+4@10' # 新しいBCDiceインスタンスを作る bcdice = BCDiceMaker.new.newBcDice # ゲームを指定する bcdice.setGameByTitle(game_title) # BCDiceに送るメッセージ(コマンド)を指定する bcdice.setMessage(command) # ダイスロールの結果(出目)を返すように設定する bcdice.setCollectRandResult(true) # ダイスロールを行い、結果を受け取る # * output:ダイスロールの結果(出目の合計など)を示すメッセージ # * 例:"2DX+4@10 : (2R10+4[10]) > 8[7,8]+4 > 12" # * secret:シークレットダイスならばtrue、そうでなければfalse output, secret = bcdice.dice_command # 出目の情報を受け取る # 2つの整数要素を持つ配列の配列として返ってくる # * 返り値の例:[[7, 10], [8, 10]](10面ダイスの7、10面ダイスの8) rolled_dice = bcdice.getRandResults </syntaxhighlight> == 利用できるダイスボットの一覧を取得する == <code>DiceBotLoader.collectDiceBots</code> を呼び出すと、利用可能なダイスボットの配列を取得することができる。これを利用して、利用できるダイスボットの一覧を作ることができる。 <syntaxhighlight lang="ruby"> # 利用できるダイスボットの配列 dicebots = DiceBotLoader.collectDiceBots # 特定のゲームを対象としないダイスボットも一覧に加える場合 # dicebots = DiceBotLoader.collectDiceBots + [DiceBot.new] # ゲーム識別子(英数字)の配列を作る game_types = dicebots.map(&:gameType) # ゲーム名(日本語)の配列を作る game_names = dicebots.map(&:gameName) </syntaxhighlight> 67f8506bd1602059fa3d32856a1f82e5c1cc6e7e BCDice/内部処理/BCDiceクラス 0 51 176 134 2020-08-24T21:27:04Z 0ヴ 9 wikitext text/x-wiki BCDiceの司令塔といえるクラス。ゲームの指定、ダイスロールなどの主要な操作は、このクラスを介して行う。 * v2.02.80.01:https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb __TOC_ == setGameByTitle == https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb#L1778-L1801 指定されたゲーム名のダイスボットを使うように設定する。 # カード機能を初期化する。 # 指定されたゲーム名のダイスボットを設定する。 ## 設定後の処理を行う(<code>diceBot.postSet</code>)。 # ゲームを設定したことを示すメッセージを返す。 <syntaxhighlight lang="ruby"> # 指定したタイトルのゲームを設定する # @param [String] gameTitle ゲームタイトル # @return [String] ゲームを設定したことを示すメッセージ def setGameByTitle(gameTitle) debug('setGameByTitle gameTitle', gameTitle) @cardTrader.initValues loader = DiceBotLoaderList.find(gameTitle) diceBot = if loader loader.loadDiceBot else DiceBotLoader.loadUnknownGame(gameTitle) || DiceBot.new end setDiceBot(diceBot) diceBot.postSet message = "Game設定を#{diceBot.gameName}に設定しました" debug( 'setGameByTitle message', message ) return message end </syntaxhighlight> == setMessage == https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb#L146-L163 ダイスボットに実行させるメッセージを設定する。 # メッセージのパターンに合わせて指定されたメッセージを加工する。 #* <code>Open Dice!</code> や <code>Open Plot!</code>、<code>Set</code> 系は指定されたメッセージそのまま。 #* それ以外の場合、空白の前まで。 # 括弧内前処理を行う。「[[#parren_killer]]」を参照。結果を <code>@messageOriginal</code> に記録する。 # 括弧内前処理の結果に対して、アルファベットを大文字にする。これを次に実行させるメッセージとして <code>@message</code> に記録する。 <syntaxhighlight lang="ruby"> def setMessage(message) # 設定で変化し得るためopen系はここで正規表現を作る openPattern = /\A\s*(?:#{$OPEN_DICE}|#{$OPEN_PLOT})\s*\z/i messageToSet = case message when openPattern, SET_COMMAND_PATTERN message else # 空白が含まれる場合、最初の部分だけを取り出す message.split(/\s/, 2).first end debug("setMessage messageToSet", messageToSet) @messageOriginal = parren_killer(messageToSet) @message = @messageOriginal.upcase debug("@message", @message) end </syntaxhighlight> == parren_killer == https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb#L1550-L1608 括弧内前処理、つまり括弧で囲まれた数式部分を還元して整数に変える処理。 BCDiceのダイス構文は正規文法ではないのに、正規表現だけで処理しようとしているため、無理矢理気味な処理となっている。また、原理上、文法エラーを検出できない場合がある。例えば、 * <code>(2*/2)d6</code> → <code>(2*/2)d6 : (1D6) > 3</code> など。 処理の流れは以下のとおり。 # <code>[<var>n</var>D<var>s</var>]</code> の加算ロールを先に実行する。実際の処理は「[[#rollDiceAddingUp]]」が担当する。 # 範囲構文を数字に変える。「[[#changeRangeTextToNumberText]]」を参照。 # 括弧に入った四則演算(<code>+-*/</code>)を処理する。 # <code><var>n</var>D</code> が残っていたら、<code><var>n</var>D6</code> に変える。 <syntaxhighlight lang="ruby"> def parren_killer(string) debug("parren_killer input", string) while( /^(.*?)\[(\d+[Dd]\d+)\](.*)/ =~ string ) str_before = "" str_after = "" dice_cmd = $2 str_before = $1 if($1) str_after = $3 if($3) rolled, dmy = rollDiceAddingUp(dice_cmd) string = "#{str_before}#{rolled}#{str_after}" end string = changeRangeTextToNumberText(string) while(/^(.*?)(\([\d\/*+-]+?\))(.*)/ =~ string) debug("while string", string) str_a = $3 str_a ||= "" str_b = $1 str_b ||= "" debug("str_b", str_b) par_i = $2 debug("par_i", par_i) par_o = paren_k(par_i) debug("par_o", par_o) if(par_o != 0) if(par_o < 0) if(/(.+?)(\+)$/ =~ str_b) str_b = $1 elsif(/(.+?)(-)$/ =~ str_b) str_b = "#{$1}+" par_o = par_o * -1 end end string = "#{str_b}#{par_o}#{str_a}" else if(/^([DBRUdbru][\d]+)(.*)/ =~ $str_a) str_a = $2 end string = "#{str_b}0#{str_a}" end end debug("diceBot.changeText(string) begin", string) string = @diceBot.changeText(string) debug("diceBot.changeText(string) end", string) string = string.gsub(/([\d]+[dD])([^\d\w]|$)/) {"#{$1}6#{$2}"} debug("parren_killer output", string) return string end </syntaxhighlight> == setCollectRandResult == https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb#L1046-L1052 出目を記録するかどうかを設定するメソッドのようだが、実際には、引数 <code>b</code> に <code>true</code> を設定すると記録スロットを初期化するという動作になっている。<code>false</code> を設定すると記録スロットが <code>nil</code> でクリアされる。 <syntaxhighlight lang="ruby"> def setCollectRandResult(b) if( b ) @randResults = [] else @randResults = nil end end </syntaxhighlight> == dice_command == https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb#L769-L801 ダイスロールを実行する。以下の順で、実行できる処理があればそれを実行し、できなければ次の処理を試すことを繰り返す。 # 指定されたゲームシステムの固有コマンド # D66ロール # 加算ロール <code><var>x</var>D<var>n</var></code> # バラバラロール <code><var>x</var>B<var></var></code> # 個数振り足しロール <code><var>x</var>R<var>n</var></code> # 上方無限ロール <code><var>x</var>U<var>n</var></code> # ランダム選択 <code>choice[<var>A</var>, <var>B</var>, ...]</code> # 独自の表から項目を引く 戻り値は、結果のメッセージと、シークレットロールかどうか。すべての処理に失敗した場合は結果のメッセージが <code>"1"</code> となることに注意。これはPerl時代の名残りと思われる。 <syntaxhighlight lang="ruby"> def dice_command # ダイスコマンドの分岐処理 arg = @message.upcase debug('dice_command arg', arg) output, secret = @diceBot.dice_command(@message, @nick_e) return output, secret if( output != '1' ) output, secret = rollD66(arg) return output, secret unless( output.nil? ) output, secret = checkAddRoll(arg) return output, secret unless( output.nil? ) output, secret = checkBDice(arg) return output, secret unless( output.nil? ) output, secret = checkRnDice(arg) return output, secret unless( output.nil? ) output, secret = checkUpperRoll(arg) return output, secret unless( output.nil? ) output, secret = checkChoiceCommand(arg) return output, secret unless( output.nil? ) output, secret = getTableDataResult(arg) return output, secret unless( output.nil? ) output = '1' secret = false return output, secret end </syntaxhighlight> {{DEFAULTSORT:BCDice くらす}} [[Category:BCDice/内部処理]] 00529d99572c9d53960cdec98bfb4b2d24e8c3a8 191 176 2020-08-24T22:45:12Z 118.10.82.175 0 [[Special:Contributions/0ヴ|0ヴ]] ([[User talk:0ヴ|トーク]]) による版 176 を取り消し wikitext text/x-wiki BCDiceの司令塔といえるクラス。ゲームの指定、ダイスロールなどの主要な操作は、このクラスを介して行う。 * v2.02.80.01:https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb __TOC__ == setGameByTitle == https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb#L1778-L1801 指定されたゲーム名のダイスボットを使うように設定する。 # カード機能を初期化する。 # 指定されたゲーム名のダイスボットを設定する。 ## 設定後の処理を行う(<code>diceBot.postSet</code>)。 # ゲームを設定したことを示すメッセージを返す。 <syntaxhighlight lang="ruby"> # 指定したタイトルのゲームを設定する # @param [String] gameTitle ゲームタイトル # @return [String] ゲームを設定したことを示すメッセージ def setGameByTitle(gameTitle) debug('setGameByTitle gameTitle', gameTitle) @cardTrader.initValues loader = DiceBotLoaderList.find(gameTitle) diceBot = if loader loader.loadDiceBot else DiceBotLoader.loadUnknownGame(gameTitle) || DiceBot.new end setDiceBot(diceBot) diceBot.postSet message = "Game設定を#{diceBot.gameName}に設定しました" debug( 'setGameByTitle message', message ) return message end </syntaxhighlight> == setMessage == https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb#L146-L163 ダイスボットに実行させるメッセージを設定する。 # メッセージのパターンに合わせて指定されたメッセージを加工する。 #* <code>Open Dice!</code> や <code>Open Plot!</code>、<code>Set</code> 系は指定されたメッセージそのまま。 #* それ以外の場合、空白の前まで。 # 括弧内前処理を行う。「[[#parren_killer]]」を参照。結果を <code>@messageOriginal</code> に記録する。 # 括弧内前処理の結果に対して、アルファベットを大文字にする。これを次に実行させるメッセージとして <code>@message</code> に記録する。 <syntaxhighlight lang="ruby"> def setMessage(message) # 設定で変化し得るためopen系はここで正規表現を作る openPattern = /\A\s*(?:#{$OPEN_DICE}|#{$OPEN_PLOT})\s*\z/i messageToSet = case message when openPattern, SET_COMMAND_PATTERN message else # 空白が含まれる場合、最初の部分だけを取り出す message.split(/\s/, 2).first end debug("setMessage messageToSet", messageToSet) @messageOriginal = parren_killer(messageToSet) @message = @messageOriginal.upcase debug("@message", @message) end </syntaxhighlight> == parren_killer == https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb#L1550-L1608 括弧内前処理、つまり括弧で囲まれた数式部分を還元して整数に変える処理。 BCDiceのダイス構文は正規文法ではないのに、正規表現だけで処理しようとしているため、無理矢理気味な処理となっている。また、原理上、文法エラーを検出できない場合がある。例えば、 * <code>(2*/2)d6</code> → <code>(2*/2)d6 : (1D6) > 3</code> など。 処理の流れは以下のとおり。 # <code>[<var>n</var>D<var>s</var>]</code> の加算ロールを先に実行する。実際の処理は「[[#rollDiceAddingUp]]」が担当する。 # 範囲構文を数字に変える。「[[#changeRangeTextToNumberText]]」を参照。 # 括弧に入った四則演算(<code>+-*/</code>)を処理する。 # <code><var>n</var>D</code> が残っていたら、<code><var>n</var>D6</code> に変える。 <syntaxhighlight lang="ruby"> def parren_killer(string) debug("parren_killer input", string) while( /^(.*?)\[(\d+[Dd]\d+)\](.*)/ =~ string ) str_before = "" str_after = "" dice_cmd = $2 str_before = $1 if($1) str_after = $3 if($3) rolled, dmy = rollDiceAddingUp(dice_cmd) string = "#{str_before}#{rolled}#{str_after}" end string = changeRangeTextToNumberText(string) while(/^(.*?)(\([\d\/*+-]+?\))(.*)/ =~ string) debug("while string", string) str_a = $3 str_a ||= "" str_b = $1 str_b ||= "" debug("str_b", str_b) par_i = $2 debug("par_i", par_i) par_o = paren_k(par_i) debug("par_o", par_o) if(par_o != 0) if(par_o < 0) if(/(.+?)(\+)$/ =~ str_b) str_b = $1 elsif(/(.+?)(-)$/ =~ str_b) str_b = "#{$1}+" par_o = par_o * -1 end end string = "#{str_b}#{par_o}#{str_a}" else if(/^([DBRUdbru][\d]+)(.*)/ =~ $str_a) str_a = $2 end string = "#{str_b}0#{str_a}" end end debug("diceBot.changeText(string) begin", string) string = @diceBot.changeText(string) debug("diceBot.changeText(string) end", string) string = string.gsub(/([\d]+[dD])([^\d\w]|$)/) {"#{$1}6#{$2}"} debug("parren_killer output", string) return string end </syntaxhighlight> == setCollectRandResult == https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb#L1046-L1052 出目を記録するかどうかを設定するメソッドのようだが、実際には、引数 <code>b</code> に <code>true</code> を設定すると記録スロットを初期化するという動作になっている。<code>false</code> を設定すると記録スロットが <code>nil</code> でクリアされる。 <syntaxhighlight lang="ruby"> def setCollectRandResult(b) if( b ) @randResults = [] else @randResults = nil end end </syntaxhighlight> == dice_command == https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/bcdiceCore.rb#L769-L801 ダイスロールを実行する。以下の順で、実行できる処理があればそれを実行し、できなければ次の処理を試すことを繰り返す。 # 指定されたゲームシステムの固有コマンド # D66ロール # 加算ロール <code><var>x</var>D<var>n</var></code> # バラバラロール <code><var>x</var>B<var></var></code> # 個数振り足しロール <code><var>x</var>R<var>n</var></code> # 上方無限ロール <code><var>x</var>U<var>n</var></code> # ランダム選択 <code>choice[<var>A</var>, <var>B</var>, ...]</code> # 独自の表から項目を引く 戻り値は、結果のメッセージと、シークレットロールかどうか。すべての処理に失敗した場合は結果のメッセージが <code>"1"</code> となることに注意。これはPerl時代の名残りと思われる。 <syntaxhighlight lang="ruby"> def dice_command # ダイスコマンドの分岐処理 arg = @message.upcase debug('dice_command arg', arg) output, secret = @diceBot.dice_command(@message, @nick_e) return output, secret if( output != '1' ) output, secret = rollD66(arg) return output, secret unless( output.nil? ) output, secret = checkAddRoll(arg) return output, secret unless( output.nil? ) output, secret = checkBDice(arg) return output, secret unless( output.nil? ) output, secret = checkRnDice(arg) return output, secret unless( output.nil? ) output, secret = checkUpperRoll(arg) return output, secret unless( output.nil? ) output, secret = checkChoiceCommand(arg) return output, secret unless( output.nil? ) output, secret = getTableDataResult(arg) return output, secret unless( output.nil? ) output = '1' secret = false return output, secret end </syntaxhighlight> {{DEFAULTSORT:BCDice くらす}} [[Category:BCDice/内部処理]] ea8d56043aad0068f77b3dfc7a669200effb691c IRC 0 14 177 142 2020-08-24T21:28:16Z 0ヴ 9 wikitext text/x-wiki '''IRC'''(Internet Relay Chat)は、チャットプロトコルのひとつ。1990年代からTRPGのオンラインセッションに利用されている == 概要 == 古くからある高速、軽快なチャットプロトコル。1988年にフィンランドのプログラマJarkko Oikarinenによって開発された<ref>[http://www.irc.org/history_docs/jarkko.html IRC History by Jarkko Oikarinen - IRC.org]</ref>。[[Skype]]や[[Discord]]などが普及する以前は、チャットにおける事実上の標準プロトコルだった<ref>[http://hiki.trpg.net/wiki/?IRC 旧TRPG.NET Wiki - IRC]</ref>。 IRCによるチャットを行うには、クライアントソフトウェア(クライアント)と呼ばれる専用のプログラムを使う。用意されたサーバへクライアントを使用して接続することで、多くのユーザがほぼリアルタイムの会話を行える。IRCはあくまでプロトコルであるため、クライアントが対応していれば、PCやタブレット端末、スマートフォンといった様々な種類の端末からチャットに参加できる。また、クライアントには多くの種類があり、ユーザが好みのものを使うことができる。 == TRPGのオンラインセッションにおけるIRCの利用 == 2000年代前半まではチャットにおける事実上の標準プロトコルだったため、TRPGのオンラインセッションにIRCがよく利用されていた。より高機能なチャットプラットフォームが普及した現在も廃れてはおらず、一定数の利用者がいる。基本的には文章のみでセッションを進めることになるが、アップロードした画像のURLを送信する、[[ダイスボット]]というダイスロールを模倣するプログラムを利用するなどの方法により、より多くの情報を導入することができる。 日本では、1990年代後半に[[TRPG.NET]]がIRCネットワークirc.trpg.net系の運用を開始し、このIRCネットワークがオンラインセッションに多く利用されてきた。irc.trpg.net系は、現在[[irc.cre.jp系]]として運用されている。 == 規格 == 1993年に、Jarkko Oikarinenが[https://tools.ietf.org/html/rfc1459 RFC 1459]([http://web.archive.org/web/20111228003516/http://www.haun.org/kent/lib/rfc1459-irc-ja.html 日本語訳のアーカイブ])を発表した。このRFCに準拠するように、サーバソフトウェアやクライアントソフトウェアが実装されてきた。 2000年には、Christophe Kaltが以下の4つのRFCを発表した。 * [https://tools.ietf.org/html/rfc2810 RFC 2810]([http://web.archive.org/web/20070705011756/http://www.alt-r.com/lib/rfc2810j.html 日本語訳のアーカイブ]):アーキテクチャ * [https://tools.ietf.org/html/rfc2811 RFC 2811]([http://web.archive.org/web/20070403224951/http://www.alt-r.com/lib/rfc2811j.html 日本語訳のアーカイブ]):チャンネル管理 * [https://tools.ietf.org/html/rfc2812 RFC 2812]([http://web.archive.org/web/20070701072918/http://www.alt-r.com/lib/rfc2812j.html 日本語訳のアーカイブ]):クライアントプロトコル * [https://tools.ietf.org/html/rfc2813 RFC 2813]([http://web.archive.org/web/20070617180733/http://www.alt-r.com/lib/rfc2813j.html 日本語訳のアーカイブ]):サーバプロトコル 2014年には、Richard Hartmannが[https://tools.ietf.org/html/rfc7194 RFC 7194]を発表した。このRFCでは、TLS/SSLを利用してIRCの通信を暗号化する「ircs-u」の内容が述べられている。 2019年現在、[https://ircv3.net IRCv3 Working Group]が、より現代的なプロトコルにしようと作業を進めている。 == 脚注 == <references /> [[Category:チャット]] [[Category:IRC|*IRC]] 38c6347448094e1c79380a319b4e740464a06da9 198 177 2020-08-26T22:38:32Z 2400:4153:84E0:AC00:B5C3:DB95:924F:6C8E 0 [[Special:Contributions/0ヴ|0ヴ]] ([[User talk:0ヴ|トーク]]) による版 177 を取り消し wikitext text/x-wiki '''IRC'''(Internet Relay Chat)は、チャットプロトコルのひとつ。1990年代からTRPGのオンラインセッションに利用されている。 == 概要 == 古くからある高速、軽快なチャットプロトコル。1988年にフィンランドのプログラマJarkko Oikarinenによって開発された<ref>[http://www.irc.org/history_docs/jarkko.html IRC History by Jarkko Oikarinen - IRC.org]</ref>。[[Skype]]や[[Discord]]などが普及する以前は、チャットにおける事実上の標準プロトコルだった<ref>[http://hiki.trpg.net/wiki/?IRC 旧TRPG.NET Wiki - IRC]</ref>。 IRCによるチャットを行うには、クライアントソフトウェア(クライアント)と呼ばれる専用のプログラムを使う。用意されたサーバへクライアントを使用して接続することで、多くのユーザがほぼリアルタイムの会話を行える。IRCはあくまでプロトコルであるため、クライアントが対応していれば、PCやタブレット端末、スマートフォンといった様々な種類の端末からチャットに参加できる。また、クライアントには多くの種類があり、ユーザが好みのものを使うことができる。 == TRPGのオンラインセッションにおけるIRCの利用 == 2000年代前半まではチャットにおける事実上の標準プロトコルだったため、TRPGのオンラインセッションにIRCがよく利用されていた。より高機能なチャットプラットフォームが普及した現在も廃れてはおらず、一定数の利用者がいる。基本的には文章のみでセッションを進めることになるが、アップロードした画像のURLを送信する、[[ダイスボット]]というダイスロールを模倣するプログラムを利用するなどの方法により、より多くの情報を導入することができる。 日本では、1990年代後半に[[TRPG.NET]]がIRCネットワークirc.trpg.net系の運用を開始し、このIRCネットワークがオンラインセッションに多く利用されてきた。irc.trpg.net系は、現在[[irc.cre.jp系]]として運用されている。 == 規格 == 1993年に、Jarkko Oikarinenが[https://tools.ietf.org/html/rfc1459 RFC 1459]([http://web.archive.org/web/20111228003516/http://www.haun.org/kent/lib/rfc1459-irc-ja.html 日本語訳のアーカイブ])を発表した。このRFCに準拠するように、サーバソフトウェアやクライアントソフトウェアが実装されてきた。 2000年には、Christophe Kaltが以下の4つのRFCを発表した。 * [https://tools.ietf.org/html/rfc2810 RFC 2810]([http://web.archive.org/web/20070705011756/http://www.alt-r.com/lib/rfc2810j.html 日本語訳のアーカイブ]):アーキテクチャ * [https://tools.ietf.org/html/rfc2811 RFC 2811]([http://web.archive.org/web/20070403224951/http://www.alt-r.com/lib/rfc2811j.html 日本語訳のアーカイブ]):チャンネル管理 * [https://tools.ietf.org/html/rfc2812 RFC 2812]([http://web.archive.org/web/20070701072918/http://www.alt-r.com/lib/rfc2812j.html 日本語訳のアーカイブ]):クライアントプロトコル * [https://tools.ietf.org/html/rfc2813 RFC 2813]([http://web.archive.org/web/20070617180733/http://www.alt-r.com/lib/rfc2813j.html 日本語訳のアーカイブ]):サーバプロトコル 2014年には、Richard Hartmannが[https://tools.ietf.org/html/rfc7194 RFC 7194]を発表した。このRFCでは、TLS/SSLを利用してIRCの通信を暗号化する「ircs-u」の内容が述べられている。 2019年現在、[https://ircv3.net IRCv3 Working Group]が、より現代的なプロトコルにしようと作業を進めている。 == 脚注 == <references /> [[Category:チャット]] [[Category:IRC|*IRC]] 63975890adb677b4640d51ff10925b095e8cee20 BCDice/内部処理/AddDiceクラス 0 53 178 144 2020-08-24T21:29:24Z 0ヴ 9 wikitext text/x-wiki 加算ロールの演算処理を担うクラス。 * v2.02.80.01:https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/dice/AddDice.rb __TOC_ == getSlashedDice == https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/dice/AddDice.rb#L290-L311 ダイスロール結果の除算を行う。接尾辞 <code>U</code> や <code>R</code> によって丸め処理の方法を指定することができる。 例: * <code>4D10</code> の結果が <code>30</code> のとき ** 切り捨て:<code>4D10/7</code> → 4.2… → 4 ** 四捨五入:<code>4D10/7R</code> → 4.2… → 4 ** 切り上げ:<code>4D10/7U</code> → 4.2… → 5 * <code>4D10</code> の結果が <code>32</code> のとき ** 切り捨て:<code>4D10/7</code> → 4.5… → 4 ** 四捨五入:<code>4D10/7R</code> → 4.5… → 5 ** 切り上げ:<code>4D10/7U</code> → 4.5… → 5 <syntaxhighlight lang="ruby"> def getSlashedDice(slashMark, dice) return dice unless( /^\/(\d+)(.)?$/i === slashMark ) rate = $1.to_i mark = $2 return dice if( rate == 0 ) value = (1.0 * dice / rate) case mark when "U" dice = value.ceil when "R" dice = value.round else dice = value.floor end return dice end </syntaxhighlight> {{DEFAULTSORT:AddDice くらす}} [[Category:BCDice/内部処理]] 6a16f2cc6a815b225dc8ef3766a5a73a45c0cadc 199 178 2020-08-26T22:39:04Z 2400:4153:84E0:AC00:B5C3:DB95:924F:6C8E 0 [[Special:Contributions/0ヴ|0ヴ]] ([[User talk:0ヴ|トーク]]) による版 178 を取り消し wikitext text/x-wiki 加算ロールの演算処理を担うクラス。 * v2.02.80.01:https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/dice/AddDice.rb __TOC__ == getSlashedDice == https://github.com/torgtaitai/BCDice/blob/86b8dd03ae00f8ea6a8787f9f514a5d83b2e3d41/src/dice/AddDice.rb#L290-L311 ダイスロール結果の除算を行う。接尾辞 <code>U</code> や <code>R</code> によって丸め処理の方法を指定することができる。 例: * <code>4D10</code> の結果が <code>30</code> のとき ** 切り捨て:<code>4D10/7</code> → 4.2… → 4 ** 四捨五入:<code>4D10/7R</code> → 4.2… → 4 ** 切り上げ:<code>4D10/7U</code> → 4.2… → 5 * <code>4D10</code> の結果が <code>32</code> のとき ** 切り捨て:<code>4D10/7</code> → 4.5… → 4 ** 四捨五入:<code>4D10/7R</code> → 4.5… → 5 ** 切り上げ:<code>4D10/7U</code> → 4.5… → 5 <syntaxhighlight lang="ruby"> def getSlashedDice(slashMark, dice) return dice unless( /^\/(\d+)(.)?$/i === slashMark ) rate = $1.to_i mark = $2 return dice if( rate == 0 ) value = (1.0 * dice / rate) case mark when "U" dice = value.ceil when "R" dice = value.round else dice = value.floor end return dice end </syntaxhighlight> {{DEFAULTSORT:AddDice くらす}} [[Category:BCDice/内部処理]] 54e38d22e06b4657f7430bad5f086ff41af9b40d BCDice/TRPGツールからの呼び出し方 0 15 179 146 2020-08-24T21:30:50Z 0ヴ 9 wikitext text/x-wiki 本ページ以下では、様々なオンラインセッションツールから現在の[[BCDice]]をどのように呼び出しているかをまとめる == Rubyで書かれたBCDiceを使用するツール == === BCDiceの全機能を利用するツール === * [[/どどんとふ]] === ダイスロールのみを利用するツール === 呼び出し方の概要:[[/ダイスロールのみ利用する場合]] * [[/BCDice-API]] * [[/Onset!]] * [[/オンセンルーム]] == BCDice-APIを使用するツール == * [[Quoridorn]] ** v1.0.0b12:[https://github.com/HillTopTRPG/quoridorn-vue-cli-3/blob/bc39e134a367325a09c0e5257e5c50f9a91237a7/src/store/state_setting.ts#L51-L119 src/store/state_setting.ts#L51-L119] に呼び出す処理がある。 * [[Saipage]] ** コミット 723cbdb:[https://github.com/ysakasin/saipage/blob/723cbdbc20ad830e31dd6096bfcb39b14266bf49/client/dice.ts client/dice.ts] に呼び出す処理がある。 == JavaScriptに変換したBCDiceを使用するツール == BCDiceをOpalでJavaScriptに変換して使用する。 * [[ねこ卓]]:[https://github.com/bcdice/bcdice-js bcdice-js]を使用する。 * [[ユドナリウム]] [[Category:BCDice]] {{DEFAULTSORT:TRPGつうるからのよひたしかた}} 67fd1f118dbcae912e812b802592ced629e147fa 200 179 2020-08-26T22:39:46Z 2400:4153:84E0:AC00:B5C3:DB95:924F:6C8E 0 [[Special:Contributions/0ヴ|0ヴ]] ([[User talk:0ヴ|トーク]]) による版 179 を取り消し wikitext text/x-wiki 本ページ以下では、様々なオンラインセッションツールから現在の[[BCDice]]をどのように呼び出しているかをまとめる。 == Rubyで書かれたBCDiceを使用するツール == === BCDiceの全機能を利用するツール === * [[/どどんとふ]] === ダイスロールのみを利用するツール === 呼び出し方の概要:[[/ダイスロールのみ利用する場合]] * [[/BCDice-API]] * [[/Onset!]] * [[/オンセンルーム]] == BCDice-APIを使用するツール == * [[Quoridorn]] ** v1.0.0b12:[https://github.com/HillTopTRPG/quoridorn-vue-cli-3/blob/bc39e134a367325a09c0e5257e5c50f9a91237a7/src/store/state_setting.ts#L51-L119 src/store/state_setting.ts#L51-L119] に呼び出す処理がある。 * [[Saipage]] ** コミット 723cbdb:[https://github.com/ysakasin/saipage/blob/723cbdbc20ad830e31dd6096bfcb39b14266bf49/client/dice.ts client/dice.ts] に呼び出す処理がある。 == JavaScriptに変換したBCDiceを使用するツール == BCDiceをOpalでJavaScriptに変換して使用する。 * [[ねこ卓]]:[https://github.com/bcdice/bcdice-js bcdice-js]を使用する。 * [[ユドナリウム]] [[Category:BCDice]] {{DEFAULTSORT:TRPGつうるからのよひたしかた}} 3e8f6758ed9e192e3e532ad868478f1b33643b4d BCDice-API 0 64 180 159 2020-08-24T21:32:02Z 0ヴ 9 wikitext text/x-wiki {{TRPGツール概要 | 開発者 = [https://twitter.com/ysakasin 酒田 シンジ] | GitHubリポジトリ = [https://github.com/bcdice/bcdice-api bcdice/bcdice-api] | 使用技術 = [[Ruby]] }} '''BCDice-API'''は、ダイスボットWebAPIのひとつ。 [https://twitter.com/ysakasin 酒田 シンジ]を中心として開発が進められている == 概要 == [[BCDice]]を振るためのWebAPI。[[Saipage]]をはじめとした多くのTRPGツールに使用されている。 そのままの状態のBCDiceはライブラリとして利用するには不便であるため、他のプログラムからダイスロールを簡単に得るために開発された。BCDice-APIは現在[[どどんとふ公式鯖]]に設置されており、TRPGツールの開発において気軽にBCDiceを利用することができる。 == 設置されている主なサーバ == 公開サーバは、[https://github.com/bcdice/bcdice-api-servers GitHub上のリポジトリ]で一覧できる。 また、[https://api-status.bcdice.org BCDice-API バージョン一覧]では、公開サーバで利用可能なBCDice-API及びBCDice本体のバージョンが分かる。 == 関連項目 == [[Category:ダイスボット]] [[Category:BCDice|*BCDice]] a7556f57176e50a94733a769349fcc7e31feb729 201 180 2020-08-26T22:40:31Z 2400:4153:84E0:AC00:B5C3:DB95:924F:6C8E 0 [[Special:Contributions/0ヴ|0ヴ]] ([[User talk:0ヴ|トーク]]) による版 180 を取り消し wikitext text/x-wiki {{TRPGツール概要 | 開発者 = [https://twitter.com/ysakasin 酒田 シンジ] | GitHubリポジトリ = [https://github.com/bcdice/bcdice-api bcdice/bcdice-api] | 使用技術 = [[Ruby]] }} '''BCDice-API'''は、ダイスボットWebAPIのひとつ。 [https://twitter.com/ysakasin 酒田 シンジ]を中心として開発が進められている。 == 概要 == [[BCDice]]を振るためのWebAPI。[[Saipage]]をはじめとした多くのTRPGツールに使用されている。 そのままの状態のBCDiceはライブラリとして利用するには不便であるため、他のプログラムからダイスロールを簡単に得るために開発された。BCDice-APIは現在[[どどんとふ公式鯖]]に設置されており、TRPGツールの開発において気軽にBCDiceを利用することができる。 == 設置されている主なサーバ == 公開サーバは、[https://github.com/bcdice/bcdice-api-servers GitHub上のリポジトリ]で一覧できる。 また、[https://api-status.bcdice.org BCDice-API バージョン一覧]では、公開サーバで利用可能なBCDice-API及びBCDice本体のバージョンが分かる。 == 関連項目 == [[Category:ダイスボット]] [[Category:BCDice|*BCDice]] b2e099b17beac151e7614d51abe01f281358b973 BCDice 0 16 181 160 2020-08-24T21:33:17Z 0ヴ 9 wikitext text/x-wiki {{TRPGツール概要 | 開発者 = ; Perl版 :[https://twitter.com/Faceless192x Faceless] ; Ruby版 :[https://twitter.com/torgtaitai たいたい竹流] ; v3 :[https://twitter.com/ysakasin 酒田 シンジ]等 | 公式サイト = [https://bcdice.org BCDice] | GitHubリポジトリ = [https://github.com/bcdice/BCDice bcdice/BCDice] | 使用技術 = [[Ruby]] }} '''BCDice'''(ボーンズ&カーズ)は、ダイスボットのひとつ。[[どどんとふ]]をはじめとした多くのTRPGツールに使用されている。現在は 現在は[https://twitter.com/ysakasin 酒田 シンジ]を中心として、開発が進められている == 概要 == 多くの日本製ゲームシステムに対応したダイスボット。[[どどんとふ]]をはじめとした多くのTRPGツールに使用されており、広く普及している。 開発当初はIRCボットとしての使用が前提だったが、Rubyへの移植以来、ライブラリとしての使用が増えた。ライブラリとしては「どどんとふのダイスボット」という位置付けだったが、2016年に[[Onset!]]で採用され、その他のTRPGツールでも利用されるようになってきた。 TRPGツールからのBCDiceの利用を容易にするために、HTTP経由での利用を可能とする[[BCDice-API]]も開発されている。BCDice-APIは現在[[どどんとふ公式鯖]]などに設置されており、TRPGツールの開発において気軽にBCDiceを利用することができる。 その他にも、新しいゲームシステムに対応したダイスボットの開発や内部処理の改善などで、多くの者が開発に参加している。 == 歴史 == Perlで書かれた[[IRC]]ボットとして[https://twitter.com/Faceless192x Faceless氏]によって開発され、[http://faceless-tools.cocolog-nifty.com/blog/2008/02/ver1015_2788.html 2008年に公開された]。 その後、2011年に[https://twitter.com/torgtaitai たいたい竹流氏]によって[[Ruby]]に移植され、どどんとふへの対応が強化された。 2020年、Flashの終了に伴い[[どどんとふ]]の開発終了が宣言された後、[https://twitter.com/ysakasin 酒田 シンジ]氏がメンテナンスを引き継ぎ、現在はコミュニティベースでの開発が行なわれている。 == 関連項目 == * [[/TRPGツールからの呼び出し方]] * [[/内部処理]] [[Category:ダイスボット]] [[Category:BCDice|*BCDice]] eea4002e732065b2d73f98a4d9553cfa931ff939 202 181 2020-08-26T22:41:16Z 2400:4153:84E0:AC00:B5C3:DB95:924F:6C8E 0 [[Special:Contributions/0ヴ|0ヴ]] ([[User talk:0ヴ|トーク]]) による版 181 を取り消し wikitext text/x-wiki {{TRPGツール概要 | 開発者 = ; Perl版 :[https://twitter.com/Faceless192x Faceless] ; Ruby版 :[https://twitter.com/torgtaitai たいたい竹流] ; v3 :[https://twitter.com/ysakasin 酒田 シンジ]等 | 公式サイト = [https://bcdice.org BCDice] | GitHubリポジトリ = [https://github.com/bcdice/BCDice bcdice/BCDice] | 使用技術 = [[Ruby]] }} '''BCDice'''(ボーンズ&カーズ)は、ダイスボットのひとつ。[[どどんとふ]]をはじめとした多くのTRPGツールに使用されている。現在は 現在は[https://twitter.com/ysakasin 酒田 シンジ]を中心として、開発が進められている。 == 概要 == 多くの日本製ゲームシステムに対応したダイスボット。[[どどんとふ]]をはじめとした多くのTRPGツールに使用されており、広く普及している。 開発当初はIRCボットとしての使用が前提だったが、Rubyへの移植以来、ライブラリとしての使用が増えた。ライブラリとしては「どどんとふのダイスボット」という位置付けだったが、2016年に[[Onset!]]で採用され、その他のTRPGツールでも利用されるようになってきた。 TRPGツールからのBCDiceの利用を容易にするために、HTTP経由での利用を可能とする[[BCDice-API]]も開発されている。BCDice-APIは現在[[どどんとふ公式鯖]]などに設置されており、TRPGツールの開発において気軽にBCDiceを利用することができる。 その他にも、新しいゲームシステムに対応したダイスボットの開発や内部処理の改善などで、多くの者が開発に参加している。 == 歴史 == Perlで書かれた[[IRC]]ボットとして[https://twitter.com/Faceless192x Faceless氏]によって開発され、[http://faceless-tools.cocolog-nifty.com/blog/2008/02/ver1015_2788.html 2008年に公開された]。 その後、2011年に[https://twitter.com/torgtaitai たいたい竹流氏]によって[[Ruby]]に移植され、どどんとふへの対応が強化された。 2020年、Flashの終了に伴い[[どどんとふ]]の開発終了が宣言された後、[https://twitter.com/ysakasin 酒田 シンジ]氏がメンテナンスを引き継ぎ、現在はコミュニティベースでの開発が行なわれている。 == 関連項目 == * [[/TRPGツールからの呼び出し方]] * [[/内部処理]] [[Category:ダイスボット]] [[Category:BCDice|*BCDice]] f894634123e616550bd8faa658e48397fb9bb445 メインページ 0 1 219 218 2020-08-29T21:26:43Z 0ヴ 9 /* ようこそ TRPGツール開発・運用Wiki へ */ wikitext text/x-wiki __NOTOC__ == ようこそ {{SITENAME}} へ == オープンソースのTRPGツールの開発や運用に関する情報をまとめるwikiです。ツールの設置の仕方や使われている要素技術など、開発や運用に役立つ情報をまとめていきましょう。 現在、{{SITENAME}}には約 [[Special:Statistics|{{NUMBEROFARTICLES}}]] 本の記事があり == 主要なTRPGツール == === Webアプリケーション === * [[どどんとふ]] ** [[ひよんとふ]](ひよこどどんとふクライアント) * [[ユドナリウム]] * [[オンセンルーム]]([[TRPGオンラインセッションSNS]]) * [[ねこ卓]] * [[Quoridorn]] * [[Onset!]] * [[Saider]] * [[Saipage]] === ダイスボット === * [[BCDice]](ボーンズ&カーズ) ** [[BCDice-API]] ** [[discord-bcdicebot]] * [[RGR == 公開サーバー == * [[どどんとふ公式鯖]] * [[どどんとふむせる]] * [[コノスサーバー]] * [[TRPG.NET]] == チャットプラットフォーム == * [[Discord]] * [[IRC]] ** [[irc.cre.jp系]] [[Category:{{SITENAME}}]] {{DEFAULTSORT:めいんへえし}} f278800637c4295ee34da1055e41049d79f85072 220 219 2020-08-30T08:01:28Z Ochaochaocha3 1 [[Special:Contributions/0ヴ|0ヴ]] ([[User talk:0ヴ|トーク]]) による編集を [[User:118.10.82.175|118.10.82.175]] による直前の版へ差し戻しました wikitext text/x-wiki __NOTOC__ == ようこそ {{SITENAME}} へ == オープンソースのTRPGツールの開発や運用に関する情報をまとめるwikiです。ツールの設置の仕方や使われている要素技術など、開発や運用に役立つ情報をまとめていきましょう。 現在、{{SITENAME}}には約 [[Special:Statistics|{{NUMBEROFARTICLES}}]] 本の記事がありま == 主要なTRPGツール == === Webアプリケーション === * [[どどんとふ]] ** [[ひよんとふ]](ひよこどどんとふクライアント) * [[ユドナリウム]] * [[オンセンルーム]]([[TRPGオンラインセッションSNS]]) * [[ねこ卓]] * [[Quoridorn]] * [[Onset!]] * [[Saider]] * [[Saipage]] === ダイスボット === * [[BCDice]](ボーンズ&カーズ) ** [[BCDice-API]] ** [[discord-bcdicebot]] * [[RGRB == 公開サーバー == * [[どどんとふ公式鯖]] * [[どどんとふむせる]] * [[コノスサーバー]] * [[TRPG.NET]] == チャットプラットフォーム == * [[Discord]] * [[IRC]] ** [[irc.cre.jp系]] [[Category:{{SITENAME}}]] {{DEFAULTSORT:めいんへえし}} 3bdb30b6f4bcfcd557f3a35ebdf0419dd5b97e73 221 220 2020-08-30T08:04:52Z Ochaochaocha3 1 版140に差し戻す wikitext text/x-wiki __NOTOC__ == ようこそ {{SITENAME}} へ == オープンソースのTRPGツールの開発や運用に関する情報をまとめるwikiです。ツールの設置の仕方や使われている要素技術など、開発や運用に役立つ情報をまとめていきましょう。 現在、{{SITENAME}}には約 [[Special:Statistics|{{NUMBEROFARTICLES}}]] 本の記事があります。 == 主要なTRPGツール == === Webアプリケーション === * [[どどんとふ]] ** [[ひよんとふ]](ひよこどどんとふクライアント) * [[ユドナリウム]] * [[オンセンルーム]]([[TRPGオンラインセッションSNS]]) * [[ねこ卓]] * [[Quoridorn]] * [[Onset!]] * [[Saider]] * [[Saipage]] === ダイスボット === * [[BCDice]](ボーンズ&カーズ) ** [[BCDice-API]] ** [[discord-bcdicebot]] * [[RGRB]] == 公開サーバー == * [[どどんとふ公式鯖]] * [[どどんとふむせる]] * [[コノスサーバー]] * [[TRPG.NET]] == チャットプラットフォーム == * [[Discord]] * [[IRC]] ** [[irc.cre.jp系]] [[Category:{{SITENAME}}]] {{DEFAULTSORT:めいんへえし}} 561ea799ce35a5e1ed20ce24123b29517a81ad15 irc.cre.jp系 0 52 222 207 2020-08-30T08:05:20Z Ochaochaocha3 1 [[Special:Contributions/2400:4153:84E0:AC00:B5C3:DB95:924F:6C8E|2400:4153:84E0:AC00:B5C3:DB95:924F:6C8E]] ([[User talk:2400:4153:84E0:AC00:B5C3:DB95:924F:6C8E|トーク]]) による版 207 を取り消し wikitext text/x-wiki 「irc.cre.jp系IRCサーバ群」を正式名称とする、[[クリエイターズネットワーク]]が提供する[[IRC]]ネットワークである。旧称「TRPG.NET系」。 2019年現在、日本には他に、独立系のIRCネットワークとしてFriendChat系や[https://www.irc.city.tokyo-3.jp/ 第3新東京市]系などがある。これらのIRCネットワークと比較したときの特徴は以下の通りである。 * 利用可能なニックネームが長い(31文字まで使用可能。プロトコル上は9文字まで、他の多くのネットワークでは25文字まで) * ダイス機能を含む公式のボットが提供されている([[Toybox/Role]]) * チャットには、一部の環境依存文字を含む、多くの文字が使用可能(UTF-8 を採用している) * IRC プロトコルの標準的なサーバ(ircd2.11)を使っていない * [[NickServ]] などの、管理サービスが使用可 24ca1bbbd767f3ce25215c8dae83cf88050c1a50 223 222 2020-08-30T08:05:33Z Ochaochaocha3 1 [[Special:Contributions/0ヴ|0ヴ]] ([[User talk:0ヴ|トーク]]) による版 186 を取り消し wikitext text/x-wiki 「irc.cre.jp系IRCサーバ群」を正式名称とする、[[クリエイターズネットワーク]]が提供する[[IRC]]ネットワークである。旧称「TRPG.NET系」。 2019年現在、日本には他に、独立系のIRCネットワークとしてFriendChat系や[https://www.irc.city.tokyo-3.jp/ 第3新東京市]系などがある。これらのIRCネットワークと比較したときの特徴は以下の通りである。 * 利用可能なニックネームが長い(31文字まで使用可能。プロトコル上は9文字まで、他の多くのネットワークでは25文字まで) * ダイス機能を含む公式のボットが提供されている([[Toybox/Role]]) * チャットには、一部の環境依存文字を含む、多くの文字が使用可能(UTF-8 を採用している) * IRC プロトコルの標準的なサーバ(ircd2.11)を使っていない * [[NickServ]] などの、管理サービスが使用可能 ef461f919e1bbecbdf033130f78531716c574905 224 223 2020-08-30T08:05:47Z Ochaochaocha3 1 [[Special:Contributions/118.10.82.175|118.10.82.175]] ([[User talk:118.10.82.175|トーク]]) による版 170 を取り消し wikitext text/x-wiki '''irc.cre.jp系'''は、[[クリエイターズネットワーク]]が提供する[[IRC]]ネットワークである。正式名称は「'''irc.cre.jp系IRCサーバ群'''」。旧称「TRPG.NET系」。 == 概要 == 日本の独立系[[IRC]]ネットワーク。様々な話題のためのチャンネルでの会話のほか、設立の経緯からTRPGのオンラインセッションでの利用が多い。 2019年現在、日本の独立系[[IRC]]ネットワークには、他にFriendChat系や[https://www.irc.city.tokyo-3.jp/ 第3新東京市]系などがある。これらのIRCネットワークと比較したときの特徴は以下の通りである。 * 利用可能なニックネームが長い(31文字まで使用可能。プロトコル上は9文字まで、他の多くのネットワークでは25文字まで) * ダイス機能を含む公式のボットが提供されている([[Toybox/Role]]) * チャットには、一部の環境依存文字を含む、多くの文字が使用可能(UTF-8 を採用している) * IRC プロトコルの標準的なサーバ(ircd2.11)を使っていない * [[NickServ]] などの、管理サービスが使用可能 == 関連項目 == * [[クリエイターズネットワーク]] {{DEFAULTSORT:irc.cre.jpけい}} [[Category:IRC]] 18bcfd15ea7d04fa153edef7ab7e0392bd689976 BCDice/TRPGツールからの呼び出し方/Onset! 0 21 225 206 2020-08-30T08:06:15Z Ochaochaocha3 1 [[Special:Contributions/2400:4153:84E0:AC00:B5C3:DB95:924F:6C8E|2400:4153:84E0:AC00:B5C3:DB95:924F:6C8E]] ([[User talk:2400:4153:84E0:AC00:B5C3:DB95:924F:6C8E|トーク]]) による版 206 を取り消し wikitext text/x-wiki [[Onset!]]からの[[BCDice]]の呼び出し方。[https://github.com/kiridaruma/Onset/releases/tag/v2.1.3 v2.1.3]のソースコードを参考にしている。 ツール本体は[[PHP]]製だが、[[Ruby]]で書かれた簡潔なラッパースクリプトを[[CGI]]で呼び出している。 __TOC_ == Onset/public_html/bcdice/roll.rb L31-L36 == https://github.com/kiridaruma/Onset/blob/297e66de6b799198cdf17036e12f89c7506fcd65/Onset/public_html/bcdice/roll.rb#L31-L36 クエリパラメータ <code>list=1</code> がついていた場合、ゲームシステム一覧を出力する。 <syntaxhighlight lang="ruby"> if(params['list'][0] == "1") $allGameTypes.each do |var| puts var + "\n" end exit end </syntaxhighlight> == Onset/public_html/bcdice/roll.rb L47-L55 == https://github.com/kiridaruma/Onset/blob/297e66de6b799198cdf17055e12f89c7506fcd65/Onset/public_html/bcdice/roll.rb#L47-L55 ダイスロールを行う。 <syntaxhighlight lang="ruby"> bcmaker = OnsetBCDiceMaker.new bcdice = bcmaker.newBcDice() bcdice.setGameByTitle(params['sys'][0]) bcdice.setMessage(params['text'][0]) bcdice.setNick('onset') hoge, foo = bcdice.dice_command puts hoge </syntaxhighlight> == Onset/public_html/bcdice/roll.rb L11-L24 == https://github.com/kiridaruma/Onset/blob/297e66de6b799198cdf17055e12f89c7506fcd65/Onset/public_html/bcdice/roll.rb#L11-L24 <code>OnsetBCDice</code> クラスは、Onset!のインターフェースに合わせてニックネームを設定する機能を付加している。<code>OnsetBCDiceMaker</code> クラスは、BCDiceのインスタンス作成時に <code>OnsetBCDice</code> クラスを使うようにする。 <syntaxhighlight lang="ruby"> class OnsetBCDiceMaker < BCDiceMaker def newBcDice bcdice = OnsetBCDice.new(self, @cardTrader, @diceBot, @counterInfos, @tableFileData) return bcdice end end class OnsetBCDice < BCDice def setNick(nick) @nick_e = nick end end </syntaxhighlight> [[Category:BCDice/TRPGツールからの呼び出し方]] 55813a8fe25d45ef72c0a7f1ad0c8ee5387a9f35 226 225 2020-08-30T08:06:28Z Ochaochaocha3 1 [[Special:Contributions/0ヴ|0ヴ]] ([[User talk:0ヴ|トーク]]) による版 185 を取り消し wikitext text/x-wiki [[Onset!]]からの[[BCDice]]の呼び出し方。[https://github.com/kiridaruma/Onset/releases/tag/v2.1.3 v2.1.3]のソースコードを参考にしている。 ツール本体は[[PHP]]製だが、[[Ruby]]で書かれた簡潔なラッパースクリプトを[[CGI]]で呼び出している。 __TOC__ == Onset/public_html/bcdice/roll.rb L31-L36 == https://github.com/kiridaruma/Onset/blob/297e66de6b799198cdf17036e12f89c7506fcd65/Onset/public_html/bcdice/roll.rb#L31-L36 クエリパラメータ <code>list=1</code> がついていた場合、ゲームシステム一覧を出力する。 <syntaxhighlight lang="ruby"> if(params['list'][0] == "1") $allGameTypes.each do |var| puts var + "\n" end exit end </syntaxhighlight> == Onset/public_html/bcdice/roll.rb L47-L55 == https://github.com/kiridaruma/Onset/blob/297e66de6b799198cdf17055e12f89c7506fcd65/Onset/public_html/bcdice/roll.rb#L47-L55 ダイスロールを行う。 <syntaxhighlight lang="ruby"> bcmaker = OnsetBCDiceMaker.new bcdice = bcmaker.newBcDice() bcdice.setGameByTitle(params['sys'][0]) bcdice.setMessage(params['text'][0]) bcdice.setNick('onset') hoge, foo = bcdice.dice_command puts hoge </syntaxhighlight> == Onset/public_html/bcdice/roll.rb L11-L24 == https://github.com/kiridaruma/Onset/blob/297e66de6b799198cdf17055e12f89c7506fcd65/Onset/public_html/bcdice/roll.rb#L11-L24 <code>OnsetBCDice</code> クラスは、Onset!のインターフェースに合わせてニックネームを設定する機能を付加している。<code>OnsetBCDiceMaker</code> クラスは、BCDiceのインスタンス作成時に <code>OnsetBCDice</code> クラスを使うようにする。 <syntaxhighlight lang="ruby"> class OnsetBCDiceMaker < BCDiceMaker def newBcDice bcdice = OnsetBCDice.new(self, @cardTrader, @diceBot, @counterInfos, @tableFileData) return bcdice end end class OnsetBCDice < BCDice def setNick(nick) @nick_e = nick end end </syntaxhighlight> [[Category:BCDice/TRPGツールからの呼び出し方]] 202438f5154e02f8e0c460bb9f469305e58bca32 227 226 2020-08-30T08:06:38Z Ochaochaocha3 1 [[Special:Contributions/118.10.82.175|118.10.82.175]] ([[User talk:118.10.82.175|トーク]]) による版 169 を取り消し wikitext text/x-wiki [[Onset!]]からの[[BCDice]]の呼び出し方。[https://github.com/kiridaruma/Onset/releases/tag/v2.1.3 v2.1.3]のソースコードを参考にしている。 ツール本体は[[PHP]]製だが、[[Ruby]]で書かれた簡潔なラッパースクリプトを[[CGI]]で呼び出している。 __TOC__ == Onset/public_html/bcdice/roll.rb L31-L36 == https://github.com/kiridaruma/Onset/blob/297e66de6b799198cdf17036e12f89c7506fcd65/Onset/public_html/bcdice/roll.rb#L31-L36 クエリパラメータ <code>list=1</code> がついていた場合、ゲームシステム一覧を出力する。 <syntaxhighlight lang="ruby"> if(params['list'][0] == "1") $allGameTypes.each do |var| puts var + "\n" end exit end </syntaxhighlight> == Onset/public_html/bcdice/roll.rb L47-L55 == https://github.com/kiridaruma/Onset/blob/297e66de6b799198cdf17055e12f89c7506fcd65/Onset/public_html/bcdice/roll.rb#L47-L55 ダイスロールを行う。 <syntaxhighlight lang="ruby"> bcmaker = OnsetBCDiceMaker.new bcdice = bcmaker.newBcDice() bcdice.setGameByTitle(params['sys'][0]) bcdice.setMessage(params['text'][0]) bcdice.setNick('onset') hoge, foo = bcdice.dice_command puts hoge </syntaxhighlight> == Onset/public_html/bcdice/roll.rb L11-L24 == https://github.com/kiridaruma/Onset/blob/297e66de6b799198cdf17055e12f89c7506fcd65/Onset/public_html/bcdice/roll.rb#L11-L24 <code>OnsetBCDice</code> クラスは、Onset!のインターフェースに合わせてニックネームを設定する機能を付加している。<code>OnsetBCDiceMaker</code> クラスは、BCDiceのインスタンス作成時に <code>OnsetBCDice</code> クラスを使うようにする。 <syntaxhighlight lang="ruby"> class OnsetBCDiceMaker < BCDiceMaker def newBcDice bcdice = OnsetBCDice.new(self, @cardTrader, @diceBot, @counterInfos, @tableFileData) return bcdice end end class OnsetBCDice < BCDice def setNick(nick) @nick_e = nick end end </syntaxhighlight> {{DEFAULTSORT:Onset}} [[Category:BCDice/TRPGツールからの呼び出し方]] 51a8b38e159a5ee003b75f2b000b634a40b093e2 BCDice/TRPGツールからの呼び出し方/BCDice-API 0 17 228 205 2020-08-30T08:07:08Z Ochaochaocha3 1 版120に差し戻す wikitext text/x-wiki [[BCDice-API]]からの[[BCDice]]の呼び出し方。[https://github.com/ysakasin/bcdice-api/releases/tag/0.6.2 v0.6.2]のソースコードを参考にしている。 == server.rb L74-L78 == https://github.com/ysakasin/bcdice-api/blob/0dfd095a4c7befed58ffbb7eb880a9d729badf2a/server.rb#L74-L78 パス `/v1/diceroll` にリクエストが来たときの処理。ダイスロールを行う。 <syntaxhighlight lang="ruby"> get "/v1/diceroll" do result, secret, dices = diceroll(params[:system], params[:command]) jsonp ok: true, result: result, secret: secret, dices: dices end </syntaxhighlight> == server.rb L20-L42 == https://github.com/ysakasin/bcdice-api/blob/0dfd095a4c7befed58ffbb7eb880a9d729badf2a/server.rb#L20-L42 ダイスロールを行うメソッド。 <syntaxhighlight lang="ruby"> def diceroll(system, command) dicebot = BCDice::DICEBOTS[system] if dicebot.nil? raise UnsupportedDicebot end if command.nil? || command.empty? raise CommandError end bcdice = BCDiceMaker.new.newBcDice bcdice.setDiceBot(dicebot) bcdice.setMessage(command) bcdice.setCollectRandResult(true) result, secret = bcdice.dice_command dices = bcdice.getRandResults.map {|dice| {faces: dice[1], value: dice[0]}} if result.nil? raise CommandError end return result, secret, dices end </syntaxhighlight> {{DEFAULTSORT:BCDice API}} [[Category:BCDice/TRPGツールからの呼び出し方]] 886608273f763972c208044ca06bc9fe6ac1d6a4 どどんとふ 0 10 229 204 2020-08-30T08:07:30Z Ochaochaocha3 1 [[Special:Contributions/2400:4153:84E0:AC00:B5C3:DB95:924F:6C8E|2400:4153:84E0:AC00:B5C3:DB95:924F:6C8E]] ([[User talk:2400:4153:84E0:AC00:B5C3:DB95:924F:6C8E|トーク]]) による版 204 を取り消し wikitext text/x-wiki {{TRPGツール概要 | image = ファイル:dodontof-screenshot.png | キャプション = どどんとふのスクリーンショット | 開発者 = [https://twitter.com/torgtaitai たいたい竹流] | 公式サイト = [http://www.dodontof.com/ どどんとふ@えくすとり~む] | 公式マニュアル = [http://www.melonbooks.com/index.php?main_page=product_info&products_id=IT0000197863 どどんとふで始める初めてのオンラインセッション2017年夏の号!] | GitHubリポジトリ = [https://github.com/torgtaitai/DodontoF torgtaitai/DodontoF] | 使用技術 = [[Flash]]、[[Ruby]] }} '''どどんとふ'''は、[https://twitter.com/torgtaitai たいたい竹流氏]によって開発されているオンラインセッションツール == 概要 == オンラインセッションに必要な多くの機能を備えた、総合オンラインセッションツール。部屋の作成、チャット、ダイスボット、キャラクター管理、マップ管理、イニシアティブ表といった基本的な機能に加えて、以下のような豊富な機能を搭載している<ref name="official-manual">[http://www.melonbooks.com/index.php?main_page=product_info&products_id=IT0000197863 どどんとふで始める初めてのオンラインセッション2017年夏の号!]</ref>。 * 秘話チャット * シークレットダイス * ダイスシンボル * 共有メモ * カード * 資源管理 * 範囲 * 魔法タイマー * チット設置 * マップ手書き * 画像のアップロード * Webカメラ撮影 * 立ち絵 * ノベルゲーム風表示 * カットイン * 読み上げ * リプレイ録画 * 多言語対応 === ダイスボット === ダイスボットとして[[BCDice]](ボーンズ&カーズ)を使用している。現在のBCDiceは、どどんとふ環境で動作することを前提として開発、テストされている。様々なゲームシステムのダイスロールおよび表引きに加え、独自の表の追加、カード機能などBCDiceの機能をフル活用しているのは、どどんとふならではである。 == Flashの廃止に伴う影響 == どどんとふのクライアントプログラム(プレイヤーが操作する画面のプログラム)は、[[Flash]]を使用して作られている。Flashは2020年に廃止されることが決定しており、2021年以降、通常はブラウザからクライアントプログラムを動作させることができなくなる。そのため、[[どどんとふ公式鯖]]<ref>[https://twitter.com/DoDontoF_Srv/status/1112201807239901184 どどんとふ公式鯖とねこ卓公式鯖と氷丼公式鯖中の人さんのツイート: "2020年12月にどどんとふ公式鯖終了がかなり濃厚です。HTML5版を残すかは開発体制状況次第です。 Quoridornやねこ卓その他ツールは継続予定ですが、サーバー負荷は激減するけど収益も激減するのは確実なので、そこら辺をどうするかも課題です。無罪になったのにCoinhive無くなっちゃうしなあ。"]</ref>や[[どどんとふむせる]]<ref>[http://museru.blog.jp/archives/1066846255.html どどんとふ「むせる」の終了時期について : むせるいんふぉめーしょん]</ref>では、管理者が2020年にどどんとふの提供を終了することを宣言している。 なお、[[Ruby]]で書かれているどどんとふのサーバープログラムは、Flash廃止の影響を受けず、2021年以降も動作する。そのため、クライアントプログラムのみ[[HTML5]]で書き直す試みが行われている(kitt氏の[[HTML5版どどんとふ]])。HTML5版のクライアントが十分に動作するようになれば、2021年以降もどどんとふを使ってオンラインセッションを楽しむことができる可能性はある。 == 設置 == === 小規模サーバー === 以下の説明は公式マニュアル<ref name="official-manual" />を基にしている。 少人数で使用する場合は、[[Ruby]](1.8.7以上)が使えるレンタルサーバーにファイルを置き、パーミッションの設定をするだけでよい。マニュアルでは、さくらインターネットのレンタルサーバー([https://www.sakura.ne.jp/ さくらのレンタルサーバ])が推奨されている。 まず、公式サイトの[http://www.dodontof.com/index.php?option=com_content&view=article&id=246&Itemid=126 ダウンロードページ]から最新版または安定版のzipファイルをダウンロードし、展開する。さくらのレンタルサーバでアカウント名が「trpg_net」の場合、展開したファイルを以下のように配置し、パーミッションを設定する。 <pre> home +- trpg_net +- www | +- DodontoF (705) | | +- DodontoFServer.rb (705) | | +- log.txt (600) | | +- log.txt.0 (600) | | +- saveDataTempSpace (705) | | +- fileUploadSpace (705) | | +- replayDataUploadSpace (705) | +- imageUploadSpace (705) | +- smallImages (705) +- saveData (705) </pre> ファイルの配置およびパーミッション設定が完了したら、ブラウザから <code>DodontoF/DodontoFServer.rb</code> を開く。上記の例の場合、URLは <pre>http://trpg_net.sakura.ne.jp/DodontoF/DodontoFServer.rb</pre> となる。ファイルの配置およびパーミッション設定が正しくできていれば、以下のように表示される。 <syntaxhighlight lang="json"> ["「どどんとふ」の動作環境は正常に起動しています。"] </syntaxhighlight> 上記のメッセージが表示されたら、<code>DodontoF/DodontoF.swf</code> を開く。上記の例の場合、URLは <pre>http://trpg_net.sakura.ne.jp/DodontoF/DodontoF.swf</pre> となる。 === 大規模サーバー === レンタルサーバーを使う場合、快適に使用できる人数は10人程度までであり、それ以上の人数では負荷が重くなる。大規模なサーバーでは、以下のような構成とする例が多い。 * より高性能なサーバーやVPSを使う。 ** SSDを使う。 ** メモリに余裕があれば、RAMディスクを使う。 ** 必要に応じて、TCP/IPに関するLinuxカーネルのチューニングを行う。 * Webサーバーとしてnginxを使う。 * 最新のRubyを使う。 * FastCGIを使う。 ** spawn-fcgiなどでサーバープログラムを起動する。 ** Gem「fcgi」を使う。 * Gem「msgpack」を使う。 * 擬似cometモードを使わない。 設置の手順を解説している記事として、以下のものがある。 * [http://cre.jp/techblog/2016/01/27/dodontof-centos7-nginx-spawn/ クリエイターズネットワーク技術部ブログ » CentOS7+nginx+spawn-fcgi でどどんとふを動かす] ** [[TRPG.NET]]へのどどんとふの設置時の作業を基にしている。 * 大ちゃんのいろいろ雑記 - どどんとふをdebian+nginxで動かすやり方(nginxセットアップ編)@公式鯖3rdシリーズ ** [[どどんとふ公式鯖]]へのどどんとふ設置作業の記録。ハードウェアの性能を満たすのは難しいが、各要素は参考になる。 *# [https://www.taruki.com/wp/?p=6099 OS編] *# [https://www.taruki.com/wp/?p=6123 nginxセットアップ編] *# [https://www.taruki.com/wp/?p=6133 fcgi編] *# [https://www.taruki.com/wp/?p=6160 どどんとふ本体編] *# [https://www.taruki.com/wp/?p=6162 運用ツール編(最低限)] *# [https://www.taruki.com/wp/?p=6165 運用ツール編(その他)] *# [https://www.taruki.com/wp/?p=6182 運用ツール編(負荷グラフ)] == 脚注 == <references /> [[Category:TRPGツール]] {{DEFAULTSORT:ととんとふ}} 63daab96314db30bdc1db381c4065cb91237e807 230 229 2020-08-30T08:07:44Z Ochaochaocha3 1 [[Special:Contributions/0ヴ|0ヴ]] ([[User talk:0ヴ|トーク]]) による版 183 を取り消し wikitext text/x-wiki {{TRPGツール概要 | image = ファイル:dodontof-screenshot.png | キャプション = どどんとふのスクリーンショット | 開発者 = [https://twitter.com/torgtaitai たいたい竹流] | 公式サイト = [http://www.dodontof.com/ どどんとふ@えくすとり~む] | 公式マニュアル = [http://www.melonbooks.com/index.php?main_page=product_info&products_id=IT0000197863 どどんとふで始める初めてのオンラインセッション2017年夏の号!] | GitHubリポジトリ = [https://github.com/torgtaitai/DodontoF torgtaitai/DodontoF] | 使用技術 = [[Flash]]、[[Ruby]] }} '''どどんとふ'''は、[https://twitter.com/torgtaitai たいたい竹流氏]によって開発されているオンラインセッションツール。 == 概要 == オンラインセッションに必要な多くの機能を備えた、総合オンラインセッションツール。部屋の作成、チャット、ダイスボット、キャラクター管理、マップ管理、イニシアティブ表といった基本的な機能に加えて、以下のような豊富な機能を搭載している<ref name="official-manual">[http://www.melonbooks.com/index.php?main_page=product_info&products_id=IT0000197863 どどんとふで始める初めてのオンラインセッション2017年夏の号!]</ref>。 * 秘話チャット * シークレットダイス * ダイスシンボル * 共有メモ * カード * 資源管理 * 範囲 * 魔法タイマー * チット設置 * マップ手書き * 画像のアップロード * Webカメラ撮影 * 立ち絵 * ノベルゲーム風表示 * カットイン * 読み上げ * リプレイ録画 * 多言語対応 === ダイスボット === ダイスボットとして[[BCDice]](ボーンズ&カーズ)を使用している。現在のBCDiceは、どどんとふ環境で動作することを前提として開発、テストされている。様々なゲームシステムのダイスロールおよび表引きに加え、独自の表の追加、カード機能などBCDiceの機能をフル活用しているのは、どどんとふならではである。 == Flashの廃止に伴う影響 == どどんとふのクライアントプログラム(プレイヤーが操作する画面のプログラム)は、[[Flash]]を使用して作られている。Flashは2020年に廃止されることが決定しており、2021年以降、通常はブラウザからクライアントプログラムを動作させることができなくなる。そのため、[[どどんとふ公式鯖]]<ref>[https://twitter.com/DoDontoF_Srv/status/1112201807239901184 どどんとふ公式鯖とねこ卓公式鯖と氷丼公式鯖中の人さんのツイート: "2020年12月にどどんとふ公式鯖終了がかなり濃厚です。HTML5版を残すかは開発体制状況次第です。 Quoridornやねこ卓その他ツールは継続予定ですが、サーバー負荷は激減するけど収益も激減するのは確実なので、そこら辺をどうするかも課題です。無罪になったのにCoinhive無くなっちゃうしなあ。"]</ref>や[[どどんとふむせる]]<ref>[http://museru.blog.jp/archives/1066846255.html どどんとふ「むせる」の終了時期について : むせるいんふぉめーしょん]</ref>では、管理者が2020年にどどんとふの提供を終了することを宣言している。 なお、[[Ruby]]で書かれているどどんとふのサーバープログラムは、Flash廃止の影響を受けず、2021年以降も動作する。そのため、クライアントプログラムのみ[[HTML5]]で書き直す試みが行われている(kitt氏の[[HTML5版どどんとふ]])。HTML5版のクライアントが十分に動作するようになれば、2021年以降もどどんとふを使ってオンラインセッションを楽しむことができる可能性はある。 == 設置 == === 小規模サーバー === 以下の説明は公式マニュアル<ref name="official-manual" />を基にしている。 少人数で使用する場合は、[[Ruby]](1.8.7以上)が使えるレンタルサーバーにファイルを置き、パーミッションの設定をするだけでよい。マニュアルでは、さくらインターネットのレンタルサーバー([https://www.sakura.ne.jp/ さくらのレンタルサーバ])が推奨されている。 まず、公式サイトの[http://www.dodontof.com/index.php?option=com_content&view=article&id=246&Itemid=126 ダウンロードページ]から最新版または安定版のzipファイルをダウンロードし、展開する。さくらのレンタルサーバでアカウント名が「trpg_net」の場合、展開したファイルを以下のように配置し、パーミッションを設定する。 <pre> home +- trpg_net +- www | +- DodontoF (705) | | +- DodontoFServer.rb (705) | | +- log.txt (600) | | +- log.txt.0 (600) | | +- saveDataTempSpace (705) | | +- fileUploadSpace (705) | | +- replayDataUploadSpace (705) | +- imageUploadSpace (705) | +- smallImages (705) +- saveData (705) </pre> ファイルの配置およびパーミッション設定が完了したら、ブラウザから <code>DodontoF/DodontoFServer.rb</code> を開く。上記の例の場合、URLは <pre>http://trpg_net.sakura.ne.jp/DodontoF/DodontoFServer.rb</pre> となる。ファイルの配置およびパーミッション設定が正しくできていれば、以下のように表示される。 <syntaxhighlight lang="json"> ["「どどんとふ」の動作環境は正常に起動しています。"] </syntaxhighlight> 上記のメッセージが表示されたら、<code>DodontoF/DodontoF.swf</code> を開く。上記の例の場合、URLは <pre>http://trpg_net.sakura.ne.jp/DodontoF/DodontoF.swf</pre> となる。 === 大規模サーバー === レンタルサーバーを使う場合、快適に使用できる人数は10人程度までであり、それ以上の人数では負荷が重くなる。大規模なサーバーでは、以下のような構成とする例が多い。 * より高性能なサーバーやVPSを使う。 ** SSDを使う。 ** メモリに余裕があれば、RAMディスクを使う。 ** 必要に応じて、TCP/IPに関するLinuxカーネルのチューニングを行う。 * Webサーバーとしてnginxを使う。 * 最新のRubyを使う。 * FastCGIを使う。 ** spawn-fcgiなどでサーバープログラムを起動する。 ** Gem「fcgi」を使う。 * Gem「msgpack」を使う。 * 擬似cometモードを使わない。 設置の手順を解説している記事として、以下のものがある。 * [http://cre.jp/techblog/2016/01/27/dodontof-centos7-nginx-spawn/ クリエイターズネットワーク技術部ブログ » CentOS7+nginx+spawn-fcgi でどどんとふを動かす] ** [[TRPG.NET]]へのどどんとふの設置時の作業を基にしている。 * 大ちゃんのいろいろ雑記 - どどんとふをdebian+nginxで動かすやり方(nginxセットアップ編)@公式鯖3rdシリーズ ** [[どどんとふ公式鯖]]へのどどんとふ設置作業の記録。ハードウェアの性能を満たすのは難しいが、各要素は参考になる。 *# [https://www.taruki.com/wp/?p=6099 OS編] *# [https://www.taruki.com/wp/?p=6123 nginxセットアップ編] *# [https://www.taruki.com/wp/?p=6133 fcgi編] *# [https://www.taruki.com/wp/?p=6160 どどんとふ本体編] *# [https://www.taruki.com/wp/?p=6162 運用ツール編(最低限)] *# [https://www.taruki.com/wp/?p=6165 運用ツール編(その他)] *# [https://www.taruki.com/wp/?p=6182 運用ツール編(負荷グラフ)] == 脚注 == <references /> [[Category:TRPGツール]] {{DEFAULTSORT:ととんとふ}} 150bec60d263d1da6b2c91f5d0bcea6b1f11b875 BCDice/TRPGツールからの呼び出し方 0 15 231 200 2020-08-30T08:09:21Z Ochaochaocha3 1 版115に差し戻す wikitext text/x-wiki 本ページ以下では、様々なオンラインセッションツールから現在の[[BCDice]]をどのように呼び出しているかをまとめる。 == Rubyで書かれたBCDiceを使用するツール == === BCDiceの全機能を利用するツール === * [[/どどんとふ]] === ダイスロールのみを利用するツール === 呼び出し方の概要:[[/ダイスロールのみ利用する場合]] * [[/BCDice-API]] * [[/Onset!]] * [[/オンセンルーム]] == BCDice-APIを使用するツール == * [[Quoridorn]] ** v1.0.0b12:[https://github.com/HillTopTRPG/quoridorn-vue-cli-3/blob/bc39e134a367325a09c0e5257e5c50f9a91237a7/src/store/state_setting.ts#L51-L119 src/store/state_setting.ts#L51-L119] に呼び出す処理がある。 * [[Saipage]] ** コミット 723cbdb:[https://github.com/ysakasin/saipage/blob/723cbdbc20ad830e31dd6096bfcb39b14266bf49/client/dice.ts client/dice.ts] に呼び出す処理がある。 == JavaScriptに変換したBCDiceを使用するツール == BCDiceをOpalでJavaScriptに変換して使用する。 * [[ねこ卓]]:[https://github.com/ukatama/bcdice-js bcdice-js]を使用する。 * [[ユドナリウム]] [[Category:BCDice]] {{DEFAULTSORT:TRPGつうるからのよひたしかた}} 0a681e4987acd50ea9e4575f644e4561b9ec46c5 BCDice/TRPGツールからの呼び出し方/オンセンルーム 0 22 232 188 2020-09-01T22:13:39Z 2400:4153:84E0:AC00:35FD:9975:1691:DBE1 0 /* rb/plug.rb L6-L13 */ wikitext text/x-wiki [[オンセンルーム]]からの[[BCDice]]の呼び出し方。v1.01.07のソースコードを参考にしている ツール本体は[[PHP]]製だが、[[Ruby]]で書かれた簡潔なラッパースクリプトを[[CGI]]で呼び出している。 == rb/plug.rb L6-L13 == 初期設定。CGIで送られてきたフラグを変数に格納している。<code>"0"</code> だとダイスロールを行い、<code>"1"</code> だとダイスボットの説明文を取得する。 <syntaxhighlight lang="ruby"> cgi=CGI.new flag="0" #0=roll 1=descript bclocation='../BCDice/src' dicebot_name='DiceBot' dicebot_command='' if !cgi['flag'].nil? && !cgi['flag'].empty? then flag=cgi['flag'] end </syntaxhighlight> == rb/plug.rb L54-L60 == 共通設定。 <syntaxhighlight lang="ruby"> bcdiceMarker=OnsenBCDiceMaker.new bcdice=bcdiceMarker.newBcDice() bcdice.setCollectRandResult(true); if File.exist?(bclocation+'/extratables') then bcdice.setDir(bclocation+'/extratables',dicebot_name) end bcdice.setGameByTitle(dicebot_name) </syntaxhighlight> == rb/plug.rb L61-L71 == ダイスロールを行う。 <syntaxhighlight lang="ruby"> if flag !="1" then bcdice.setMessage(dicebot_command) gmsg=bcdice.getMessage res_msg,secret_flag=bcdice.dice_command res_rand=bcdice.getRandResults json_array={ 'secret_flag'=>secret_flag, 'gmsg'=>gmsg, 'res_rand'=>res_rand, 'res_msg'=>res_msg } </syntaxhighlight> == rb/plug.rb L72-L77 == ダイスボットの説明文を取得する。 <syntaxhighlight lang="ruby"> else ght=bcdice.gotHelpMessage json_array={ 'ght'=>ght } end </syntaxhighlight> == rb/plug.rb L40-L53 == 独自クラスの定義。必要な機能を呼び出しやすくしているようだ。 <syntaxhighlight lang="ruby"> class OnsenBCDiceMaker<BCDiceMaker def newBcDice bcdice=OnsenBCDice.new(self,@cardTrader,@diceBot,@counterInfos,@tableFileData) return bcdice end end class OnsenBCDice<BCDice def getMessage return @message end def gotHelpMessage return @diceBot.getHelpMessage end end </syntaxhighlight> == rb/plug.rb のソースコード == アーカイブを展開しないと見られないため、rb/plug.rb のソースコードを以下に掲載する。ただし、インデントのためのタブとスペースが混在していたため、スペースのみに直してある。 <syntaxhighlight lang="ruby"> #!/bin/ruby -Ku print("Content-Type: text/plain;charset=utf-8\n\n") require 'json.rb' require 'cgi.rb' cgi=CGI.new flag="0" #0=roll 1=descript bclocation='../BCDice/src' dicebot_name='DiceBot' dicebot_command='' if !cgi['flag'].nil? && !cgi['flag'].empty? then flag=cgi['flag'] end if !cgi['bclocation'].nil? && !cgi['bclocation'].empty? then bclocation=cgi['bclocation']+'src' end if !File.exist?(bclocation) then json_array={ 'error'=>'bac_location_error' } puts json_array.to_json exit end $LOAD_PATH<<bclocation if !cgi['dicebot_name'].nil? && !cgi['dicebot_name'].empty? then dicebot_name=cgi['dicebot_name'] end if !cgi['dicebot_command'].nil? && !cgi['dicebot_command'].empty? then dicebot_command=cgi['dicebot_command'] end if flag !="1" && dicebot_command=='' then json_array={ 'error'=>'not_exist_command' } puts json_array.to_json exit end require 'bcdiceCore.rb' require 'configBcDice.rb' class OnsenBCDiceMaker<BCDiceMaker def newBcDice bcdice=OnsenBCDice.new(self,@cardTrader,@diceBot,@counterInfos,@tableFileData) return bcdice end end class OnsenBCDice<BCDice def getMessage return @message end def gotHelpMessage return @diceBot.getHelpMessage end end bcdiceMarker=OnsenBCDiceMaker.new bcdice=bcdiceMarker.newBcDice() bcdice.setCollectRandResult(true); if File.exist?(bclocation+'/extratables') then bcdice.setDir(bclocation+'/extratables',dicebot_name) end bcdice.setGameByTitle(dicebot_name) if flag !="1" then bcdice.setMessage(dicebot_command) gmsg=bcdice.getMessage res_msg,secret_flag=bcdice.dice_command res_rand=bcdice.getRandResults json_array={ 'secret_flag'=>secret_flag, 'gmsg'=>gmsg, 'res_rand'=>res_rand, 'res_msg'=>res_msg } else ght=bcdice.gotHelpMessage json_array={ 'ght'=>ght } end puts json_array.to_json </syntaxhighlight> [[Category:BCDice/TRPGツールからの呼び出し方]] {{DEFAULTSORT:おんせんるうむ}} 83351f0691dcd63887b2c25bb1acc21a42a83d99 233 232 2020-09-02T13:37:44Z Ochaochaocha3 1 [[Special:Contributions/2400:4153:84E0:AC00:35FD:9975:1691:DBE1|2400:4153:84E0:AC00:35FD:9975:1691:DBE1]] ([[User talk:2400:4153:84E0:AC00:35FD:9975:1691:DBE1|トーク]]) による編集を [[User:118.10.82.175|118.10.82.175]] による直前の版へ差し戻しました wikitext text/x-wiki [[オンセンルーム]]からの[[BCDice]]の呼び出し方。v1.01.07のソースコードを参考にしている。 ツール本体は[[PHP]]製だが、[[Ruby]]で書かれた簡潔なラッパースクリプトを[[CGI]]で呼び出している。 == rb/plug.rb L6-L13 == 初期設定。CGIで送られてきたフラグを変数に格納している。<code>"0"</code> だとダイスロールを行い、<code>"1"</code> だとダイスボットの説明文を取得する。 <syntaxhighlight lang="ruby"> cgi=CGI.new flag="0" #0=roll 1=descript bclocation='../BCDice/src' dicebot_name='DiceBot' dicebot_command='' if !cgi['flag'].nil? && !cgi['flag'].empty? then flag=cgi['flag'] end </syntaxhighlight> == rb/plug.rb L54-L60 == 共通設定。 <syntaxhighlight lang="ruby"> bcdiceMarker=OnsenBCDiceMaker.new bcdice=bcdiceMarker.newBcDice() bcdice.setCollectRandResult(true); if File.exist?(bclocation+'/extratables') then bcdice.setDir(bclocation+'/extratables',dicebot_name) end bcdice.setGameByTitle(dicebot_name) </syntaxhighlight> == rb/plug.rb L61-L71 == ダイスロールを行う。 <syntaxhighlight lang="ruby"> if flag !="1" then bcdice.setMessage(dicebot_command) gmsg=bcdice.getMessage res_msg,secret_flag=bcdice.dice_command res_rand=bcdice.getRandResults json_array={ 'secret_flag'=>secret_flag, 'gmsg'=>gmsg, 'res_rand'=>res_rand, 'res_msg'=>res_msg } </syntaxhighlight> == rb/plug.rb L72-L77 == ダイスボットの説明文を取得する。 <syntaxhighlight lang="ruby"> else ght=bcdice.gotHelpMessage json_array={ 'ght'=>ght } end </syntaxhighlight> == rb/plug.rb L40-L53 == 独自クラスの定義。必要な機能を呼び出しやすくしているようだ。 <syntaxhighlight lang="ruby"> class OnsenBCDiceMaker<BCDiceMaker def newBcDice bcdice=OnsenBCDice.new(self,@cardTrader,@diceBot,@counterInfos,@tableFileData) return bcdice end end class OnsenBCDice<BCDice def getMessage return @message end def gotHelpMessage return @diceBot.getHelpMessage end end </syntaxhighlight> == rb/plug.rb のソースコード == アーカイブを展開しないと見られないため、rb/plug.rb のソースコードを以下に掲載する。ただし、インデントのためのタブとスペースが混在していたため、スペースのみに直してある。 <syntaxhighlight lang="ruby"> #!/bin/ruby -Ku print("Content-Type: text/plain;charset=utf-8\n\n") require 'json.rb' require 'cgi.rb' cgi=CGI.new flag="0" #0=roll 1=descript bclocation='../BCDice/src' dicebot_name='DiceBot' dicebot_command='' if !cgi['flag'].nil? && !cgi['flag'].empty? then flag=cgi['flag'] end if !cgi['bclocation'].nil? && !cgi['bclocation'].empty? then bclocation=cgi['bclocation']+'src' end if !File.exist?(bclocation) then json_array={ 'error'=>'bac_location_error' } puts json_array.to_json exit end $LOAD_PATH<<bclocation if !cgi['dicebot_name'].nil? && !cgi['dicebot_name'].empty? then dicebot_name=cgi['dicebot_name'] end if !cgi['dicebot_command'].nil? && !cgi['dicebot_command'].empty? then dicebot_command=cgi['dicebot_command'] end if flag !="1" && dicebot_command=='' then json_array={ 'error'=>'not_exist_command' } puts json_array.to_json exit end require 'bcdiceCore.rb' require 'configBcDice.rb' class OnsenBCDiceMaker<BCDiceMaker def newBcDice bcdice=OnsenBCDice.new(self,@cardTrader,@diceBot,@counterInfos,@tableFileData) return bcdice end end class OnsenBCDice<BCDice def getMessage return @message end def gotHelpMessage return @diceBot.getHelpMessage end end bcdiceMarker=OnsenBCDiceMaker.new bcdice=bcdiceMarker.newBcDice() bcdice.setCollectRandResult(true); if File.exist?(bclocation+'/extratables') then bcdice.setDir(bclocation+'/extratables',dicebot_name) end bcdice.setGameByTitle(dicebot_name) if flag !="1" then bcdice.setMessage(dicebot_command) gmsg=bcdice.getMessage res_msg,secret_flag=bcdice.dice_command res_rand=bcdice.getRandResults json_array={ 'secret_flag'=>secret_flag, 'gmsg'=>gmsg, 'res_rand'=>res_rand, 'res_msg'=>res_msg } else ght=bcdice.gotHelpMessage json_array={ 'ght'=>ght } end puts json_array.to_json </syntaxhighlight> [[Category:BCDice/TRPGツールからの呼び出し方]] {{DEFAULTSORT:おんせんるうむ}} 8e932075867590176b754b22ceb6cef68201ec8b